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

GridView DataSources Example (Dynamic Object Source)

1 Answer 135 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Michael
Top achievements
Rank 1
Michael asked on 09 Mar 2012, 11:02 PM
Hello,

I've been having trouble getting this example to work in my own environment.  The Data Rows show up in the grid, however no columns are mapped. Below you will find the Xaml and code behind.  I copied and pasted the MyDataRow class from the example on the demo website... http://demos.telerik.com/silverlight/#GridView/DataSources

Version of Telerik.Windows.Controls.GridView.dll is 2011.3.1220.1040.  Does this version of the Telerik controls support the dynamic binding? 

XAML
<Grid x:Name="layoutroot" Background="white">
    <telerik:RadGridView x:Name="RadGridView1"
                         RowIndicatorVisibility="Collapsed"                    
                          />
</Grid>

CodeBehind
    ObservableCollection<MyDataRow> data = new ObservableCollection<MyDataRow>();
 
    public GridViewTest()
    {
        InitializeComponent();
 
        RadGridView1.ItemsSource = data;
    }
 
    public void AddDataRow(Node root)
    {
        MyDataRow subscribers= new MyDataRow();
        clients["TimeStamp"] = DateTime.Now;
 
        foreach (var subscriber in root.Subscribers)
        {
               subscribers[subscriber.ShortName] = subscriber.DoubleValue;
        }
 
        data.Add(clients);
    }      
}

Thanks,
Michael

1 Answer, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 13 Mar 2012, 12:13 PM
Hi Michael,

I have tested the code from the online demo. All the data was populated fine and I did not encounter any problems.
From your second code snippet, I can see that you have an object "subscribers". Then you add an object "clients" to the data. How is the "clients" object defined?

Regards,
Didie
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
GridView
Asked by
Michael
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Share this question
or