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

GridViewDataColumn Multiple Bindings

3 Answers 169 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Nasir
Top achievements
Rank 1
Nasir asked on 10 Apr 2013, 10:03 AM
Hi,

I need to bind multiple columns to different data source in a Gridview in silverlight 5. Is it possible to have a separate data source for some columns in the grid?

If not what other ways are there to achieve this.

Basically,

I need to display data in the grid for different scenarios. So I have a sequence in one column with a data source but then the user can also choose to see an alternate sequence for which I intended to add another column to the same grid and have a different data source for it. The data sources are identical in structure but would contain different data. I also considered using a different grid for each alternate sequence but that proved to be slow and clunky on the screen because the alternate sequences are added to the screen based on the user selection.

I would really appreciate a prompt response to this.

Regards,

Nasir

3 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 11 Apr 2013, 02:15 PM
Hi Nasir,

You can set a different Source for the DataMemberBinding of the column. You can also set different CellTemplates for the cells in one column setting a proper CellTemplateSelector. Please refer to our online demos for an example and let me know if you have any additional questions.

Kind regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Nasir
Top achievements
Rank 1
answered on 11 Apr 2013, 04:02 PM
Hi Didie,

Thanks for replying but I am not able to bind a item source to a GridViewDataColumn. The data source for this column must be different that the ItemSource of the GridView. The only thing I have seen possible is if your column type is ComboBox then you can set a different ItemSource to it independent of the Grid's item source. 

The demo only uses a single ItemSource on the grid. All the columns are bound to this single ItemSource i.e. Products. What if I want one of the columns to be bound to Orders in the same grid?

Regards,

Nasir.
0
Dimitrina
Telerik team
answered on 12 Apr 2013, 08:08 AM
Hello Nasir,

I am afraid that you cannot directly set a different ItemsSource for the column. What you can do is to predefine its CellTemplate(CellEditTemplate) and there place a control, any control that you can assign an ItemsSource to. You can check our online documentation on how you can place any control in the CellTemplate. 

Regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Nasir
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Nasir
Top achievements
Rank 1
Share this question
or