This is a migrated thread and some comments may be shown as answers.

Deslect a row in a grid

2 Answers 775 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dr.YSG
Top achievements
Rank 2
Dr.YSG asked on 07 Nov 2012, 04:56 PM
I need to programmatically deselect rows in a grid. I have not seen any API method for this. select() will return all rows, and select(<obj>) will select one item.

My issue is that I have 10 out of 50 selected, but now the user has done something and I need one of the 10 deselected (but the rest to remain selected).

I thought I had a brainstorm and that I could use jquery to trigger a CNTRL-CLICK:

var e = jQuery.Event("click");
e.ctrlKey = true;
$(this.gridRow).trigger(e);
Where this.gridRow refers the the DOM object which is the row in the grid (i.e. <TR> )which is currently selected. I have verified in FireBug that the value of tthis.gridRow is actually the <TR> row in the kendo Grid, and that it is currently selected. (see screen shot)

See attached screen shot which shows that firebug reporting that the this.grid is indeed a tr, and it has a click handler.

2 Answers, 1 is accepted

Sort by
0
Accepted
Vladimir Iliev
Telerik team
answered on 12 Nov 2012, 01:57 PM
Hi Yechezkal,

 

Please note that you can deselect given row by removing it's CSS class "k-state-selected". Please check the example below:

$(rowToDeselect).removeClass("k-state-selected");
Kind Regards,
Vladimir Iliev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Dr.YSG
Top achievements
Rank 2
answered on 12 Nov 2012, 04:46 PM
Works great. And solves a long standing problem I have had. Consider adding this tip to the documentation (Do you have a way of linking forum notes to the API docs?)

Tags
Grid
Asked by
Dr.YSG
Top achievements
Rank 2
Answers by
Vladimir Iliev
Telerik team
Dr.YSG
Top achievements
Rank 2
Share this question
or