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

[Solved] Problem using the Template selector with RadGridView.

1 Answer 186 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.
SivaPrasad Bevara
Top achievements
Rank 1
SivaPrasad Bevara asked on 12 Aug 2011, 01:51 PM
Hi,

I want to use the RadGridView to display the data from different tables.

So I am using Template Selector to choose the Template based on the requested table object (Creating Templates for each table object) .

I am able to choose the different Templates based on the different objects, but the problem is with the GridView headers.
I am not able to set the GridView headers with these templates. Because if we set the headers in the template, then these will repeat foreach Grid row. Also we can't hard code it in the GridView as the columns change based on the table.

And I dont want to use the "AutoGenerateColumns=true" property because some times I need to load the ComboBoxes in the GridView, which is not posible if we set "AutoGenerateColumns".
 
Please help me setting the headers for the Templates.

Regards,
SivaPrasad.B

1 Answer, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 17 Aug 2011, 04:54 PM
Hello Sivaprasad Bevara,

Typically, you use a template selector when you have more than one data template defined for the same type of objects. For example, use it if your binding source is a list of student objects and you want to apply a particular template to the part-time students. 

When you need to have completely different columns, it would be better to clear the existing column and create new columns based on the data from the bound table. Additionally for any custom logic related to the same object, you may add a CellTemplateSelector to the newly added column.

I have prepared a sample project showing this approach. I have an ItemSource with a 'Boolean' field, and ItemSource with an 'Int' field. First you may click the 'Bind to Bool source' button and then the 'Bind to Int source' one. The project is using an ObservableCollection, but the approach would be the same with another data sources.

Please refer to it and share with me if you have any further questions.

Regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

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