Last post Jun 24, 2019 02:20 PM by bruce (sqlwork.com)
Jun 20, 2019 10:06 AM|mark1961|LINK
i have a scenario whereby i am highlighting a last selected item in a grid when a user returns to the page.
this works on comparing rowid of each row to the last added rowid in an array and only adding relevant class to that row.
however if any deselections of rows are made and rowids removed from array it gets reindexed and the previous "last" rowid is no longer in that position so a different row will be highlighted.
this is due to splice being used to remove the rowid -
this.RowIds().splice($.inArray(rowId, this.RowIds()), 1);
is there a way to replace this removal method with one whereby the original element order would stay unchanged?
Jun 20, 2019 10:55 AM|AddWeb Solution|LINK
Try with this ,
You can use slice() . Try with this below example.
var myArray = ["one","two","three"];
var cloneArray = myArray.slice();
For more information please refer this below link
or try with this
Instead of removing the items from the array with splice(), why not just set the value to null or undefined , Then when you're adding a new user, you can just scan through the array to find the first available
Jun 20, 2019 12:03 PM|mark1961|LINK
this doesnt remove anything when i try it
Jun 21, 2019 06:01 AM|Wei Zhang|LINK
Could you please share your code both in front end and code behind? It will help us reproduce your problem.
Jun 24, 2019 07:15 AM|mark1961|LINK
this.ExpandedRowIds().splice($.inArray(rowId, this.ExpandedRowIds()), 1);
im wanting to maintain the order that rows are selected. by being able to recognise last row selected this row is then "highlighted" on return to the page.
I want to use the last row id in the array to identify this row, this only works until one is deselected as the above code reindexes the array so the previous "last" row id can be in a different place in the array.
so i want to remove ids from the array but maintain the same order of how they were added, then i can reliably use the last id in the array regardless of which ones are deselected.
this method would also work in highlighting the previous selected row if its the last row deselected....
does this make sense?
Jun 24, 2019 02:20 PM|bruce (sqlwork.com)|LINK
splice does not change the order, it only removes/adds to array. its suspicious that you are call splice on an array returned by a function.