i was using telerik Q2 version earlier. My code below was working fine then
foreach (object item in this.radgrdUserdetails.Items)
{
GridViewRow row = this.radgrdUserdetails.ItemsControl.ItemsGenerator.ContainerFromItem(item) as GridViewRow;
if
(row != null)
{
// business logic
}
}
The above code converts the each item in grid into a GridViewRow row.
The same code is not working when i am using this with Q3 Beta version Dll's.
Its not detecting "ItemsControl".
GridViewRow row = this.radgrdUserdetails.ItemsControl.ItemsGenerator.ContainerFromItem(item) as GridViewRow;
.
i also tried
GridViewRow
row = this.radgrdUserdetails.ItemContainerGenerator.ContainerFromItem(item) as GridViewRow;
even this is not woking as wished...
Please help me with this...
Regards,
Deepak Garla.
5 Answers, 1 is accepted
There is a new property on RadGridView called ItemsGenerator. Could you please use this property instead.
var container = this.gridView.ItemsGenerator.ContainerFromItem(myItem) // instead of var container = this.gridView.ItemsControl.ItemsGenerator.ContainerFromItem(myItem)All the best,
Milan
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Thanks for an early reply....
I have been using the code below........
foreach (object item in this.radgrdUserdetails.Items)
{
GridViewRow row = this.radgrdUserdetails.ItemsGenerator.ContainerFromItem(item) as GridViewRow;
if (row != null)
{
GridViewCellBase cell1 = (from c in row.Cells
where c.Column.UniqueName == "businessRoles"
select c).FirstOrDefault();
if (cell1 != null)
{
cell1.IsEnabled =
false;
}
}
}
it is still not working, only for first few rows the is enabled property is set to false.The rest is true.......
the same code is working fine with q2 version...
You should run the logic to disable cells every time a row is loaded. To achieve that you can use the RowLoaded event like this:
void gridView_RowLoaded(object sender, RowLoadedEventArgs e) { if (e.Row is GridViewGroupRow || e.Row is GridViewHeaderRow || e.Row is GridViewNewRow) return; this.DisableCells(e.Row as GridViewRow); } private void DisableCells(GridViewRow row) { if (row != null) { GridViewCellBase cell1 = (from c in row.Cells where c.Column.UniqueName == "businessRoles" select c).FirstOrDefault(); if (cell1 != null) { cell1.IsEnabled = false; } } }Hope this helps.
Best wishes,Milan
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Thaks for the reply,but unfortunately the code is not workiong...
this.DisableCells(e.Row as GridViewRow);
e.row in the above line is always null....
so none of the rows are getting locked...
any other approach for this?
It is very strange that the e.Row property is always null. Could you send us a project that will help us reproduce the problem?
Greetings,
Milan
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.