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

Locked columns - Get selected rows

3 Answers 592 Views
Grid
This is a migrated thread and some comments may be shown as answers.
pixi
Top achievements
Rank 1
pixi asked on 30 Dec 2015, 11:10 AM

Hi,

I have a selectable grid which has one locked column.
When using select() method to get selected rows, I get duplicated results.

If I select one row the result will contain two jQuery objects, beside the row there will also be separate jQuery object containing just the selected locked column.

Check this example: http://dojo.telerik.com/EyEMO

Is this how it should work or is this a bug?
In my case I would like to get the same results as I would get without locked column. 

3 Answers, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 30 Dec 2015, 04:10 PM
Hi Jure,

The behavior that you are describing is expected when you have locked columns, because there will be two separate TABLE elements for the data items and each data item will have two TR elements corresponding to it. The select method in such scenario will return the TR elements from the left table first and then you will get the TR elements for the right table.

Depending on your exact requirement, you could use the half of the items in the returned by the select method collection or with some simple logic, manipulate both TR elements for each selected item.

Hope this helps.


Regards,
Konstantin Dikov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Bridge24
Top achievements
Rank 1
Iron
answered on 17 Jan 2016, 05:16 AM

Hi, I have exactly the same issue, and I don't think that "The behavior that you are describing is expected"...

I am in the "change" event of the grid, and I want to know which row is selected.  Locked or not, there is only 1 row selected (related to 1 and only 1 dataitem).

Locked or not, grouped or not, the "action" I did is selecting 1 row.  
And, in fact, the "change" event is raised only 1 time, not 2.  Because I select "1" row.

When I follow the sample code for the change event, I get two items in the "selectedDataItems", and they are the same.

http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#events-change

I know that I can detect if they are the same, and "not add" them. But I think that doesn't make sense.

0
Konstantin Dikov
Telerik team
answered on 19 Jan 2016, 08:56 AM
Hi Dani,

The reason behind this behavior is the fact that each row will be rendered with two TR elements in two different tables. When an item is selected, the TR element receives a "k-state-selected" class name, which is then used for retrieving the selected items with the select method. That is why all TR elements from both tables are returned and it will be up to the developer to handle that scenario.

On a side note, returning both TR elements for each item allows the developer to perform custom logic over the entire item and not only to part of it.


Kind Regards,
Konstantin Dikov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
pixi
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Bridge24
Top achievements
Rank 1
Iron
Share this question
or