jQWidgets Forums
jQuery UI Widgets › Forums › DataTable › Unique Id problem while sorting
This topic contains 5 replies, has 3 voices, and was last updated by josephjmarini 8 years, 8 months ago.
-
Author
-
Hello everybody,
am I doing something completely wrong, or is it a mayor bug?
when I’m sorting the Datatable via
this.tableDiv.jqxDataTable("sortBy", this.columns[0].datafield, "asc");
and then I do another action, likethis.tableDiv.jqxDataTable('selectRow', sel.uid);
the wrong row will be selected.So if a row is after the sort on position 5, the uid is still the previous iud (for example 2).
Now the row on position 2 is selected, not the row I wanted to.The same bug occures on deleteRow and so on.
What can I do to fix it just in time? Any clue?
Hi t.knorr,
This is a normal behavior. When you sort the jqxDataTable all row ID’s are refreshed.
So if before the sort the second row have ID = 2 and after the sort that row goes to lets say position 7, it’s ID will be 7.Best Regards,
IvojQWidgets Team
http://www.jqwidgets.com/Hi Ivo,
So you say its normal, when I just:
this.tableDiv.jqxDataTable("sortBy", this.columns[0].datafield, "asc"); let selection = this.tableDiv.jqxDataTable("getSelection"); this.tableDiv.jqxDataTable("clearSelection"); this.tableDiv.jqxDataTable('selectRow', selection[0].uid);
The selection[0].uid is the old uid (like before the sort)
Then a other (not the
selection[0]
object) will be selected now!How can I select the previous
selection[0]
objectBest Regards,
ThomasHi t.knorr,
Please take a look at this demo:
https://www.jseditor.io/?key=select-old-row-index-after-sorting-jqxdatatableBest Regards,
IvojQWidgets Team
http://www.jqwidgets.com/I have the same problem.
How does one get the new row indexes.
I assumed that table.getRows() would return the current new row indexes after a sort
I then iterate over the array in a loop and using the loop counter this is the new index.
I get a task object from the manager and set the new table row index for this object.
This all works fine until I turn on sorting on the table.
var rows = this._dragonFlyJQXTableTasks.getRows();
for (var i = 0, size = rows.length; i < size; i++) {
// get a row.
rowData = rows[i];
task = TaskManager.getInstance().findTaskWithId(rowData.id);
if (task !== null && task !== undefined) {
task.setTableRowIndex(i);
}
}My question:
How does one get the new row indexes for a table after it has been sorted?
Do I need to do some type of refresh on the table after a sort to update the indexes?I just discover uid in the row object.
However it does not get updated to the new row position.
This appears to be the original row position when an objects is added to the table.
So my original questions:
How does one get the new row indexes for a table after it has been sorted?
Do I need to do some type of refresh on the table after a sort to update the indexes/uids? -
AuthorPosts
You must be logged in to reply to this topic.