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

Dynamic Data Binding

14 Answers 170 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Stephen Lim
Top achievements
Rank 1
Stephen Lim asked on 02 Feb 2010, 04:48 PM
Hello,


I'm looking for an appropriate control to handle the following scenario, and the GridView control seems like the best candidate.



I have a dynamic table of data. The columns are defined at runtime and can vary from instance to instance. The rows vary as well.


I wish to have the source data bound to a Grid-style control such that changes in both the source or target reflect on eachother.



I was wondering if the GridView control can achieve this? If it can, how would I go about doing so? If not, is there a suitable alternative, or any plans on implementing such a control in the future?



Thanks.

14 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 03 Feb 2010, 07:20 AM
Hello,

Indeed the grid is the best candidate for such case. If you bind the grid for example to ObservableCollection<T> you will get full synchronization between the grid and your collection.

Best wishes,
Vlad
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Stephen Lim
Top achievements
Rank 1
answered on 03 Feb 2010, 01:13 PM
I have my data source in nested collections to create a two dimensional grid:


ObservableCollection<ObservableCollection<T>>



I understand the control will handle the first collection as the rows - however, I'm still unsure as to whether or not the second observable collection will be treated as the cell values for each corresponding column.


0
Vlad
Telerik team
answered on 03 Feb 2010, 02:07 PM
Hello,

I'm not sure about your scenario however from such source you can easily create hierarchical grid - you can check the attached example for reference.

Greetings,
Vlad
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Stephen Lim
Top achievements
Rank 1
answered on 03 Feb 2010, 03:17 PM
Thanks for the Example,


Using the example as reference:

You define the columns for the expanded hierarchical grid using the MyObject class with pre-determined properties. These pre-determined properties ID and Name define the columns of the grid. 


I was wondering if instead of properties within MyObject defining the columns of the grid, a collection of objects could define the columns by replacing MyObject with an ObservableCollection. 


So if the inner collection grows - the columns grow dynamically as well. 


I'm looking for a Data grid that allows for dynamic growth (row and column) based on the data-source - which is not known until data is received.


Thanks.
0
Vlad
Telerik team
answered on 03 Feb 2010, 03:21 PM
Hello Stephen,

My DataTable for Silverlight may help you for such cases. You can check this post also for recent changes.

Sincerely yours,
Vlad
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Stephen Lim
Top achievements
Rank 1
answered on 03 Feb 2010, 03:44 PM
Thank you, exactly what I was looking for with a slight exception.


I'm not sure, it may possibly be resolved, but changes to the data in the data-grid dont seem to be propogated to their respective counterparts in the DataTable.


Is the two way bind mechanism supported?


Thanks.


0
Vlad
Telerik team
answered on 03 Feb 2010, 03:56 PM
Hello,

Indeed we are going to update this with a new version with INotifyCollectionChanged & INotifyPropertyChanged support - this will be most probably tomorrow.

I will let you know when we are ready.

Kind regards,
Vlad
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Accepted
Vlad
Telerik team
answered on 05 Feb 2010, 06:57 AM
Hello Stephen,

You can find the updated version of the DataTable here.

Sincerely yours,
Vlad
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Stephen Lim
Top achievements
Rank 1
answered on 05 Feb 2010, 12:10 PM
Thank you.


This is the sort of functionality I'm looking for.


The next question, though I'm unsure of whether to ask it here or in another thread, is whether or not this DataTable method will allow for Data Virtualization with the GridView.



Some of the tables that will be displayed by this particular control have an associated overhead with fetching data. 



This is due to the realtime nature of the data.



I'm under the impression that the GridView itself has Data/UI Virtualization.


0
Vlad
Telerik team
answered on 08 Feb 2010, 08:00 AM
Hi Stephen,

There will be no problem to use the DataTable in data virtualization scenario - you can check for example this blog post to know more how to apply the grid operations server-side:
http://blogs.telerik.com/vladimirenchev/posts/10-01-14/how_to_server_sorting_filtering_grouping_and_paging_with_radgridview_for_silverlight_without_wcf_ria_services.aspx

Best wishes,
Vlad
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Dave Wolf
Top achievements
Rank 1
Iron
answered on 04 May 2010, 06:03 PM
I implemented the Datatable and everything works good except when I try to use a context menu and get reference to the row.item.

Here is what i'm doing on my Item_Click event of the context menu.

 

Dim menu As RadContextMenu = DirectCast(sender, RadContextMenu)

 

 

Dim clickedItem As RadMenuItem = TryCast(e.OriginalSource, RadMenuItem)

 

 

Dim row As GridViewRow = menu.GetClickedElement(Of GridViewRow)()

When I do this row.Item comes back as "Property evaluation failed".

How I can get reference to the datarow of the gridview that was clicked?  I'm trying to pull a key.

 

0
Dave Wolf
Top achievements
Rank 1
Iron
answered on 04 May 2010, 06:57 PM
Please disregard that last post, I was using your original version.  I updated to the new one and it works fine.
0
varsha Motwani
Top achievements
Rank 1
answered on 19 May 2010, 10:47 AM
I have to implement similar scenario.
For me too Number of columns are dynamically generated.
Can you please share sample application which shows how to get the data from webservice and attach to the datable and then binding that table to Grid.
Thanks.
0
Vlad
Telerik team
answered on 19 May 2010, 11:47 AM
Hello,

If you want to use DataTable you may need to check my blog post to know more about how to achieve this.

Kind regards,
Vlad
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.
Tags
GridView
Asked by
Stephen Lim
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Stephen Lim
Top achievements
Rank 1
Dave Wolf
Top achievements
Rank 1
Iron
varsha Motwani
Top achievements
Rank 1
Share this question
or