javascript - JQuery Custom Column Sorting not working for columns that are alphanumeric -
i have set custom jquery column sorts work numeric or alphabetical data types can't work alphanumeric. imagine numbers sorted top , alphas go underneath cannot anything. im using bootstrap data tables , jquery. custom statements below can't see how allow them alphanumeric mixed field types. has have solution or point me in direction of find one? in advance.
/* create array values of input boxes in column */ $.fn.datatable.ext.order['dom-text'] = function(settings, col) { return this.api().column(col, { order: 'index' }).nodes().map(function(td, i) { return $('input', td).val(); }); } /* create array values of input boxes in column, parsed numbers */ $.fn.datatable.ext.order['dom-text-numeric'] = function(settings, col) { return this.api().column(col, { order: 'index' }).nodes().map(function(td, i) { return $('input', td).val() * 1; }); } /* create array values of select options in column */ $.fn.datatable.ext.order['dom-select'] = function(settings, col) { return this.api().column(col, { order: 'index' }).nodes().map(function(td, i) { return $('select', td).val(); }); } /* create array values of checkboxes in column */ $.fn.datatable.ext.order['dom-checkbox'] = function(settings, col) { return this.api().column(col, { order: 'index' }).nodes().map(function(td, i) { return $('input', td).prop('checked') ? '1' : '0'; }); } /* initialise table required column ordering data types */ $(document).ready(function() { $('#tab_logic').datatable({ "columns": [ { "orderdatatype": "dom-text-numeric" }, { "orderdatatype": "dom-text" }, { "orderdatatype": "dom-select" }, { "orderdatatype": "dom-select" }, { "orderdatatype": "dom-checkbox" } ] });
Comments
Post a Comment