I am new to Telerik,
currently using Telerik for Silverlight RadGridView controls I have a requirement to update all rows for perticular colum with value user enters in textbox on top of each Column name.
How do i loop through each row and access perticular column and update the value in the grid?
Please help in pointing me to sample codes.
Thanks
8 Answers, 1 is accepted
When changing a certain value for the items in the grid, it is recommended to use the Property to which the column is bound to. For example, if you have a couple of players listed in your RadGridView and you want to change the values for their Property "Number", what you can do is the following:
private void Button1_Click(object sender, RoutedEventArgs e)
{
for (int i=0; i<=this.playersGrid.Items.Count-1; i++)
{
Player myPlayer = this.playersGrid.Items[i] as Player;
myPlayer.Number = 4;
}
}
In this case on clicking on a button, every player's number will be changed to "4".
Furthermore, this.playersGrid.Items[i] loops through the items and this.playersGrid.Columns[i] - through the columns of the grid.
I hope that helps.
Greetings,
Maya
the Telerik team
It works,
only problem is it does update current page in the grid, how do I update all the rows in all pages of grid?
Thanks
In this case you will have to use the original items source collection ( instead of .Items) which contains all items.
Regards,
Milan
the Telerik team
Thanks
So you need to update the values of all items except the ones that were filtered out by the user?
Greetings,
Milan
the Telerik team
Thanks,
Hi Jagan,
There are several ways to do that. One of the is to cast the original ItemsSource to IQueryable and user Where to get all items that pass the filters. For example:
var allItemsThatPassFiltering =
(
this
.playersGrid.ItemsSource
as
IEnumerable)
.AsQueryable()
.Where(
this
.playersGrid.FilterDescriptors)
.OfType<Player>();
foreach
(var item
in
allItemsThatPassFiltering)
{
item.Number = 99;
}
I have also prepared a sample project which demonstrates this approach.
Sincerely yours,Milan
the Telerik team
Thanks