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

custom new row

3 Answers 14 Views
GridView
This is a migrated thread and some comments may be shown as answers.
bkagan98
Top achievements
Rank 1
bkagan98 asked on 04 May 2011, 05:28 AM
One of my grids has columns with default textboxes and boud to an observable collection data set that comes from wcf service. The question is - when user inserts new record (by pressing 'insert' button), in that new record (in edit mode) how to display comboboxes instead of standard textboxes? I don't see much info in documentation. Please advise. Thanks.

3 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 04 May 2011, 07:12 AM
Hi Boris,

I am sending you a sample project illustrating how you may achieve the desired result. Generally, the idea to create a new custom control that is aware whether the row is of type GridViewNewRow or GridViewRow and depending on this to display TextBox or RadComboBox.
  

Kind regards,
Maya
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
0
bkagan98
Top achievements
Rank 1
answered on 04 May 2011, 09:26 PM
Hi Maya,

Thanks for a sample - works perfectly. However, I have one more question: what should I change in your sample to show same combobox in edit mode also (for existing records)? Please advise. Thanks.
0
Maya
Telerik team
answered on 05 May 2011, 07:09 AM
Hello Boris,

You may slightly extend the functionality of the SelectiveEditor_Loaded event. As the "parentRow" is the corresponding row, you may get its Item whose type will be your business object. So, you may verify whether a value for a property is equal to the one you want to set the RadComboBox-editor for. 
For example:

void SelectiveEditor_Loaded(object sender, RoutedEventArgs e)
        {
            var parentRow = this.ParentOfType<GridViewRow>();
            if (parentRow is GridViewNewRow)
            {
                this.Combo.Visibility = Visibility.Visible;
                this.Combo.SetBinding(RadComboBox.SelectedValueProperty, new Binding("Description") { Mode = BindingMode.TwoWay });
                this.TextBox.Visibility = Visibility.Collapsed;
                 
            }
            else
            {
                this.Combo.Visibility = Visibility.Collapsed;
                this.TextBox.Visibility = Visibility.Visible;
 
                this.Combo.ClearValue(RadComboBox.SelectedValueProperty);
            }
            if((parentRow.Item as Item).Description == "one")
            {
                this.Combo.Visibility = Visibility.Visible;
                this.Combo.SetBinding(RadComboBox.SelectedValueProperty, new Binding("Description") { Mode = BindingMode.TwoWay });
                this.TextBox.Visibility = Visibility.Collapsed;
            }
            else
            {
                this.Combo.Visibility = Visibility.Collapsed;
                this.TextBox.Visibility = Visibility.Visible;
 
                this.Combo.ClearValue(RadComboBox.SelectedValueProperty);
            }
        }

In the case above if the value of "Description" property is "one", the editor will be a RadComboBox, otherwise - a plain TextBox.


Greetings,
Maya
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
bkagan98
Top achievements
Rank 1
Answers by
Maya
Telerik team
bkagan98
Top achievements
Rank 1
Share this question
or