Javascript OnSelect event

PlatinumGrid - Full version
Post Reply
dost
Posts: 6
Joined: Sun Jul 19, 2015 11:15 pm

Javascript OnSelect event

Post by dost » Thu Sep 29, 2016 10:10 pm

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.

dost
Posts: 6
Joined: Sun Jul 19, 2015 11:15 pm

Re: Javascript OnSelect event

Post by dost » Mon Oct 10, 2016 7:22 pm

Hi,

I found a workaround:

Code: Select all

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

Post Reply