Add sorting on input textboxes with convention over configuration
Add sorting on input textboxes with convention over configuration
AndersMalmgren
Posts: 12Questions: 0Answers: 0
I added a little functionality to the API so that you can add sorting for textboxes with convention over configuration. Please give me feedback if you guys can see problems with this approach...
The code needs the "dom-text" sorting plugin from the plugin page if you have tables with colspan you need this plugin and alsp change code
http://stackoverflow.com/questions/1166452/finding-column-index-using-jquery-when-table-contains-column-spanning-cells
[code]
$.fn.orgDataTable = $.fn.dataTable;
$.fn.dataTable = function (oInt) {
if (!oInt.aoColumnDefs) {
oInt.aoColumnDefs = [];
}
var indexes = [];
$("tbody tr:first", this).find("input:text").closest("td").each(function () {
var index = this.cellIndex;
indexes.push(index);
});
oInt.aoColumnDefs.push({ "sSortDataType": "dom-text", aTargets: indexes });
this.orgDataTable(oInt);
};
[/code]
The code needs the "dom-text" sorting plugin from the plugin page if you have tables with colspan you need this plugin and alsp change code
http://stackoverflow.com/questions/1166452/finding-column-index-using-jquery-when-table-contains-column-spanning-cells
[code]
$.fn.orgDataTable = $.fn.dataTable;
$.fn.dataTable = function (oInt) {
if (!oInt.aoColumnDefs) {
oInt.aoColumnDefs = [];
}
var indexes = [];
$("tbody tr:first", this).find("input:text").closest("td").each(function () {
var index = this.cellIndex;
indexes.push(index);
});
oInt.aoColumnDefs.push({ "sSortDataType": "dom-text", aTargets: indexes });
this.orgDataTable(oInt);
};
[/code]
This discussion has been closed.