Confused about how to sort my table when a column contains an input
Confused about how to sort my table when a column contains an input
I checked out all the links and found the following
[code]
/* Create an array with the values of all the input boxes in a column */
$.fn.dataTableExt.afnSortData['dom-text'] = function (oSettings, iColumn) {
var aData = [];
$('td:eq(' + iColumn + ') input', oSettings.oApi._fnGetTrNodes(oSettings)).each(function () {
aData.push(this.value);
});
return aData;
}
[/code]
Well I have some standard code that is used for all my different tables. The tables have all different combinations of columns. My question is what do I do next. I created this function but how do I apply it? What do I do next.
I saw the following:
[code]
$('#example').dataTable( {
"aoColumns": [
null,
null,
{ "sSortDataType": "dom-text" },
{ "sSortDataType": "dom-text", "sType": "numeric" },
{ "sSortDataType": "dom-select" },
{ "sSortDataType": "dom-checkbox" }
]
} );
[/code]
BUT I am using the same refresh code for different tables. Is there some way that I can tell dataTables how to sort by adding a class to the element of a column?
Here is what the td of the column I want to sort looks like:
[code]
[/code]
[code]
/* Create an array with the values of all the input boxes in a column */
$.fn.dataTableExt.afnSortData['dom-text'] = function (oSettings, iColumn) {
var aData = [];
$('td:eq(' + iColumn + ') input', oSettings.oApi._fnGetTrNodes(oSettings)).each(function () {
aData.push(this.value);
});
return aData;
}
[/code]
Well I have some standard code that is used for all my different tables. The tables have all different combinations of columns. My question is what do I do next. I created this function but how do I apply it? What do I do next.
I saw the following:
[code]
$('#example').dataTable( {
"aoColumns": [
null,
null,
{ "sSortDataType": "dom-text" },
{ "sSortDataType": "dom-text", "sType": "numeric" },
{ "sSortDataType": "dom-select" },
{ "sSortDataType": "dom-checkbox" }
]
} );
[/code]
BUT I am using the same refresh code for different tables. Is there some way that I can tell dataTables how to sort by adding a class to the element of a column?
Here is what the td of the column I want to sort looks like:
[code]
[/code]
This discussion has been closed.