3.0.5

Holding Highlighted rows across pages

Hi,
I've implemented multiple selects which gives me to highlight all or some rows on a page. However I want to keep these rows highlighted so that when I page forward and then page back again the rows are still highlighted.....

Any help would be much appreciated
New very impressed User
April 1,
Look at the /patches/paging1.htm - the selection in this prototype is kept across pages.
Alex (ActiveWidgets)
April 2,
This works fine however mine is slightly different. I will not be storing all the information locally like your paging process. I will be doing seperate calls to a database so you will be dealing with different chunks of data every time you move forward or backward.
Is there anyway of storing each highlighted row of each page in a highlight row array which is referenced each time a new grid is drawn to highlight any rows stored in this array.
Therefore maybe as a result you would not having to hold down cntl/shift button while scrolling through pages.

thanks in advance any help appreciated
JackL
April 14,
The 'selection' model does exactly that - stores indices of the selected (highlighted) rows in an array. To retrieve all the indices you can read 'selection/values' property:

var array = obj.getSelectionProperty("values");

The paging prototype uses the unique row indices in each page, so the highlighting works automatically across pages.

For example if you are in the page 2 and each page has 10 rows your indices will be 20, 21, 22, 23...

To assign the index values to the row model you should set 'row/values' property:

obj.setRowProperty("values", array);
Alex (ActiveWidgets)
April 14,
Hi Alex,

I see how that works now. Is it possible to use a particular column fields as the indices to the array??
Say the first column was a unique customer number??

Thanks
JackL
April 16,
Yes, as soon as the values you use for the row indices are unique and contain alphanumeric characters only. You need to assign the array of row indices to the row model using the same call:

obj.setRowProperty("values", array);

And you need to modify your data model so it will respond to data requests with custom indices as arguments, not as row numbers.

The similar thing is possible for column indices.
Alex (ActiveWidgets)
April 16,
Thanks Alex, that makes sense.

I'm using the following code to take the first column of numbers(unique 6 digit cust keys) of the selected rows.

var SeqNoArray = "";
var array = myGrid.getProperty("selection/values");
for (var i=0; i<array.length; i++){
var numx = myGrid.getDataProperty("text", array[i], 0);
SeqNoArray = SeqNoArray +numx;
numx = " ";
}

SeqNoArray is then equal to 000001000012000011000010 if I select the 1st,12th,11th,10th rows.

After a bit of scrolling forward and back I wish to redisplay the page with the rows previously selected highlighted using the following.

myGrid.setProperty("selection/values",SeqNoArray);

However this statement seems to be interpreting the array individually as the 1st,2nd and 3rd rows are the only ones selected

Any ideas where I'm going wrong???

Thanks
JackL
April 20,

This topic is archived.

See also:


Back to support forum