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

Rad gridview selecteditem issue

3 Answers 59 Views
GridView
This is a migrated thread and some comments may be shown as answers.
nivas
Top achievements
Rank 1
nivas asked on 18 Jan 2018, 11:35 AM

Hi Team,

                   I am new to silver light and Telerik. I used silver light business application 5 and telerik dll , created a report page.

dynamically added the data set in grid view. Add  mouse down event in a cell. once that cell clicked will get the data from other columns and will show another reports.

this works fine when i clicked the cell (without any filter) and also filter through selection for below code.

 GridViewRow row = grdview.ItemContainerGenerator.ContainerFromItem(this.grdview.SelectedItem) as GridViewRow;

when the column drag and drop to group the data and clicked on the cell getting null on above code.

Kindly help on to solve this ASAP.

 

 

3 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 23 Jan 2018, 10:06 AM
Hi Nivas,

Though I am not familiar with the exact setup you are using, I would like to clarify that working directly with the visual elements of the control(cells, rows) is highly not recommended due to the virtualized nature of the control. You can check out the UI Virtualization topic for more information on the matter.

For fetching the selection of RadGridView you can directly use the SelectedItem or SelectedItems properties of the control.

Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
nivas
Top achievements
Rank 1
answered on 24 Jan 2018, 11:16 AM

Thanks for relay stefan...

the task is will bind the summary report in a rad grid view once user click on a specific cell (specified column) needs to show the detail report for that respective row.

as you said i am using  SelectedItem  and all works fine without grouping. when group  a column using  (drag the column header and drop it here to group by that column)  and clicked on that specif column I get the null value from  SelectedItem  using below code but able to see the dined data in grdview.SelectedItem (attached screen shots).

GridViewRow row = grdview.ItemContainerGenerator.ContainerFromItem(this..grdview.SelectedItem) as GridViewRow;

 

thanks again for replay.

 

 

 

0
Stefan
Telerik team
answered on 26 Jan 2018, 01:40 PM
Hi Nivas,

This is due to the fact that the row corresponding to the selected item of the control is directly fetched. The data bound SelectedItem property will have its value kept when grouped, but the visual element is recycled, thus the behavior you are experiencing is reproduced. As mentioned in my previous reply, it is highly not recommended to adopt an approach of accessing the visual elements of the control directly. The recommended approach is to use the SelectedItem property instead, without accessing its visual container.

Hope this clarifies your concerns.

Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
GridView
Asked by
nivas
Top achievements
Rank 1
Answers by
Stefan
Telerik team
nivas
Top achievements
Rank 1
Share this question
or