Page 1 of 1

Javascript OnSelect event

Posted: Thu Sep 29, 2016 10:10 pm
by dost
Hi,
I'm trying to keep count of the number of rows the user has selected in a grid.
I declare an array in the page header and use a handler on the grid's OnSelect JS event to modify this array based on 'row' and 'selected' arguments.

The grid has ReadOnly = true, ShowSelectColumn = true, CanRangeSelect = true and RowSelect = true.

I've found that when the user deselcts a row, the 'row' arg for that event is set as -1 ('selected' = false as expected), and also that if I select and deselct a row several times a JS error is generated in the browser (firefox 47.0.1):
TypeError: cell.className is undefined
while (cell && (cell.className.indexOf("cell") == -1 || cell.tagName != "TD"))
JTPlatinumGrid.js (line 864, col 13)
If I keep un/selecting the row it generates more instances of this error.
Turns out this behaviour is independent of contents of OnSelect handler.

Re: Javascript OnSelect event

Posted: Mon Oct 10, 2016 7:22 pm
by dost
Hi,

I found a workaround:

Code: Select all

count = grid.SelectedCells.reduce(function (total,num) {return total+num;} );
Cheers.