I have a table that I sort using the following function:
function ReorderSupplyGP(table){
table.find('tr:not(.kn-table_summary)').sort(function (a, b) {
var tda = $(a).find('td:eq(1)').text().trim();
var tdb = $(b).find('td:eq(1)').text().trim();
var sales = {
"Purchase": 0, "Transfer": 1, "Returns": 2, "Adjustment": 3, "Inventory": 4
};
tda = sales[tda];
tdb = sales[tdb];
return tda > tdb ? 1
: tda < tdb ? -1
: 0;
}).prependTo(table);
}
It works fine, but when I print all the lines using a function:
for(x=1;x<tablebodyrow.length;x++)
{
console.log(tablebodyrow.eq(x));
}
It seems that the rows are sorted visually, but their index never changed. Is there any way to solve this problem.
source
share