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

Udate GridView Rows

8 Answers 87 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jagan
Top achievements
Rank 1
Jagan asked on 25 Jun 2010, 04:10 PM
Good Morning All,
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

Sort by
0
Maya
Telerik team
answered on 28 Jun 2010, 12:12 PM
Hi Jagan,

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Jagan
Top achievements
Rank 1
answered on 28 Jun 2010, 03:11 PM
Thanks Maya,

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
0
Milan
Telerik team
answered on 28 Jun 2010, 05:16 PM
Hi Jagan,

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Jagan
Top achievements
Rank 1
answered on 28 Jun 2010, 05:58 PM
Thanks for the Reply, my problem here is the update need to happen to final resultset in the Grid after users does all the filtering which will happen from them GRID, is there any way I can get all the filtering options user selects before doing update?

Thanks
0
Milan
Telerik team
answered on 28 Jun 2010, 07:26 PM
Hello Jagan,

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Jagan
Top achievements
Rank 1
answered on 28 Jun 2010, 07:31 PM
Excatly thats what I am trying to achive.

Thanks,
0
Milan
Telerik team
answered on 02 Jul 2010, 11:56 AM

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Jagan
Top achievements
Rank 1
answered on 02 Jul 2010, 03:30 PM
Thank you very much this exactly what I was looking for.

Thanks
Tags
GridView
Asked by
Jagan
Top achievements
Rank 1
Answers by
Maya
Telerik team
Jagan
Top achievements
Rank 1
Milan
Telerik team
Share this question
or