i have question using custom sorting option datatables. have table images in last column. images use title tag, want sort them on.
so, use code set sorting:
<script type="text/javascript"> jquery.extend( jquery.fn.datatableext.osort, { "title-string-pre": function ( ) { return a.match(/title="(.*?)"/)[1].tolowercase(); }, "title-string-asc": function ( a, b ) { return ((a < b) ? -1 : ((a > b) ? 1 : 0)); }, "title-string-desc": function ( a, b ) { return ((a < b) ? 1 : ((a > b) ? -1 : 0)); } } ); $(document).ready(function() { $('#customertable').datatable( { "aocolumndefs": [ { "bsortable": false, "atargets": [ 0,1 ] }, { "stype": "title-string-asc", "atargets": [ 4 ] } ], "bpaginate": false, "blengthchange": false, "bfilter": false, "binfo": false, "bautowidth": false, "bsortcellstop": true } ); } ); </script> however, when click on header of column 4, not work , chrome reports errors "property 'title-string-asc-desc' of object # not function" , "property 'title-string-asc-asc' of object # not function"
what doing wrong?
found answer, don't understand it.
changed { "stype": "title-string-asc", "atargets": [ 4 ] } { "stype": "title-string", "atargets": [ 4 ] }
now works. why? "title-string" defined nowhere. how can javascript link string content of title tag?
Comments
Post a Comment