Hi.
I have this piece of code that works just great. I have a hierarchical RadgridView and this code block helps to determine whether an employee has any subordinates.
I recently moved to MVVM and I don't want to create another instance of my domaincontext (ctx) in my code behind.
I would rather access my RadGridView's rows collection directly and replace the [emp in (IEnumerable<vEmployee>)ctx.vEmployees]
bit with something like [emp in this.RadGridView1.Rows]
Some help will be appreciated.
Thanks!
J
private bool HasSubordinates(vEmployee employee)
{
return
(from emp in (IEnumerable<vEmployee>)ctx.vEmployees
where emp.ReportsToID == employee.EmployeeID
select emp).Any();
}
5 Answers, 1 is accepted
You can use Items collection to achieve your goal.
All the best,Vlad
the Telerik team
i have a radgridview and i bound it with the list <object> collection , i have just direct bind it with the list by putting autogenerate columns to true.so that there are two textcolumn and three checkbox column made up in the grid as per the object binded with the list.
now i want to check all the checkbox columns for each rows on a button click in such a way that for each row at least one checkbox out of the three must be checked. but the problem is that in my silverlight project i am unable to access rows of radgridview individualy. please help me in acheiving this scenario.
The recommended approach would be to expose separate boolean properties for those CheckBox-es, iterate as mentioned previously through the Items collection and verify whether each item has at least one property set to "True".
Furthermore, another possible approach may be to handle the RowValidating/ RowValidated event and check whether after editing each item, it contains the required number of "True" values.
Maya
the Telerik team
If you do not want to expose properties bound to the IsChecked property of the CheckBox-es, you risk that the their state (checked/ unchecked) may be lost during scrolling. As by default the virtualization of the grid is turned on, the visual elements will be recycled on scrolling, which may lead to loss of data in case you count on the values of those elements. That is why my recommendation is to expose boolean properties that will ensure you get the correct values for each item.
Maya
the Telerik team