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

Hide TemplateColumn on selection of RadComboBox of another TemplateColumn Issue

2 Answers 164 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Asa'ad
Top achievements
Rank 1
Asa'ad asked on 18 Aug 2011, 11:12 AM
Hi All,

I have RadGrid with TemplateColumns, one of the cloumns has a RadComboBox in the edititemtemplate and insertitemtemplate
and in the other i have RadDatePicker in the edititemtemplate and insertitemtemplate also...

in the edit or insert mode and on the selection of the RadComboBox i need to make the other templatecolumn unvisible (the corresponding column header and the RadDatePicker).

i did this using the selectIndexedChanged of the ComboBox and to get this column and set its readonly property to true. and all works fine but i noticed that i need to rebind the Grid so the corresponding column disappear...but this causes that the selection of the Radcombobox to be unselected also since all the grid is rebinded!!!

how can i keep the selection or shall i do it in another way???

attached screen shots of my problem
hope you can help as soon as possible...

Many Thanks
Asa'ad....


2 Answers, 1 is accepted

Sort by
0
Asa'ad
Top achievements
Rank 1
answered on 21 Aug 2011, 10:20 AM
Please Help...
0
Veli
Telerik team
answered on 23 Aug 2011, 09:45 AM
Hello Asa'ad,

Attached is a test page demonstrating one approach you can use. We use the SelectedIndexChanged event of the combo to save the selected value and rebind the grid. In the NeedDataSource event handler, when the grid is rebound, we check for the selected value of the edit combo and set one or another column as ReadOnly. Finally, in the ItemDataBound event, we check if we have a saved selected value and use that as the selected value for the combo. If not, we extract the CategoryID value from the data record and use that as the selected combo value.

Note that, for this scenario to work the grid needs to meet the following conditions:

1. Only a single edited item at a time. The scenario will not work with multiple edited items.
2. Declarative columns. You need to be able to find the grid columns before databinding. This means auto-generated columns are not supported.

Veli
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
Grid
Asked by
Asa'ad
Top achievements
Rank 1
Answers by
Asa'ad
Top achievements
Rank 1
Veli
Telerik team
Share this question
or