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

Adding unbound data to a Grid with columns

2 Answers 146 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 16 Jun 2010, 09:10 PM
Hello,

I looked to the sample from the online demo, however it uses an object (myBusinessObject) which makes the data to go to the right column.
However, I am wondering if it's possible to set data for a specific column in the unbound scenario.
Something like 
dataGrid.Items.Add(0); // this would add the first row with the first column set to zero
dataGrid.Rows(0).Columns(1) = 1;  // add 1 to the 2nd column of first row

Thanks!

2 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 18 Jun 2010, 10:01 AM
Hi Ken,

 
When working with unbound data you can set & get the properties of the items in the same way as when using ItemsSource. So, there is no need to work with the UI Elements.
Thus if you have a player added to the grid's items and you want to set its property Number, you can do it in the following manner:

editedPlayer.Number = 66;

An important thing here is that the class Player needs to implement the interface INotifyPropertyChanged
I am sending you a sample project demonstrating how to add new item with a programatically set property and how to change the value of one of the elements.



Kind regards,
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
Andrew
Top achievements
Rank 1
answered on 18 Jun 2010, 03:28 PM
Hi,

Thanks for the message.

Setting properties on the bound object makes it to work in the same with how the bounded data works for the control.
The only difference is that you use Items when adding a new row instead of binding with ItemsSource.
I was looking for another option.

Thanks anyway,
Andrei.
Tags
GridView
Asked by
Andrew
Top achievements
Rank 1
Answers by
Maya
Telerik team
Andrew
Top achievements
Rank 1
Share this question
or