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

Enable/Disable control in NewRow template

3 Answers 141 Views
GridView
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 28 Feb 2011, 11:35 AM
How can I enable/disable controls that are placed inside of NewRow? I have sort of methods that return values indicating that some controls must be enabled/disabled. When I click add new row in my gridview new row template appears and what I am expecting is that some controls must be enabled/disabled depend on values returned by methods.

Is this possible?
regards

3 Answers, 1 is accepted

Sort by
0
Vanya Pavlova
Telerik team
answered on 28 Feb 2011, 02:57 PM
Hello John,

 
Can you please give us a little bit more info about this case:
Are you editing the template of GridViewNewRow and placing some controls inside its template or maybe I am missing something? It could be great if you can share a little bit more information about your scenario in order to provide you with an appropriate solution.


Regards,
Vanya Pavlova
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
John
Top achievements
Rank 1
answered on 28 Feb 2011, 03:10 PM
From what I know InsertItemTemplate looks completely like CellEditTemplate. I have prepared my CellTemplate and CellEditTemplate fore each column in my GridView. What I want is to have ability to disable/enable controls in InsertMode. For example I will have two checkboxes in first colum. When I click add button InsertRow should appear and when my method will return false - first checkbox should be disabled.
I am not editing template of new row.
0
Vanya Pavlova
Telerik team
answered on 28 Feb 2011, 04:51 PM
Hello John,

 
Thank you for the detailed description. In this case you may define the appropriate template for this column, place this CheckBox control and bind its IsEnabled property to the property value of the underlying business object. You may use the following forum thread for further reference:

<DataTemplate x:Key="st">
             <CheckBox IsChecked="{Binding IsChecked}" IsEnabled="{Binding IsChecked,Mode=TwoWay}"/>
 </DataTemplate>

public MainWindow()
      {
          InitializeComponent();
          List<CustomObject> list = new List<CustomObject>();
          CustomObject m1 = new CustomObject();
          m1.IsChecked = false;
          list.Add(m1);
          m1 = new CustomObject();
          m1.IsChecked = true;
          list.Add(m1);
          m1 = new CustomObject();
          m1.IsChecked = false;
          list.Add(m1);
          m1 = new CustomObject();
          m1.IsChecked = true;
          list.Add(m1);
          m1 = new CustomObject();
          m1.IsChecked = true;
          list.Add(m1);
          m1 = new CustomObject();
          m1.IsChecked = true;
          list.Add(m1);
          m1 = new CustomObject();
          m1.IsChecked = true;
          list.Add(m1);
          m1 = new CustomObject();
          m1.IsChecked = true;
          list.Add(m1);
          this.grid.ItemsSource = list;
          
      }
  }
  public class CustomObject : INotifyPropertyChanged
  {
      private bool? _isChecked;
      public bool? IsChecked
      {
          get { return _isChecked; }
          set
          {
              _isChecked = value;
              OnPropertyChanged("IsChecked");
          }
      }
      #region INotifyPropertyChanged Members
      protected virtual void OnPropertyChanged(string propertyName)
      {
          if (PropertyChanged != null)
              PropertyChanged(this, new PropertyChangedEventArgs("IsChecked"));
      }
      public event PropertyChangedEventHandler PropertyChanged;
      #endregion
  }



Regards,
Vanya Pavlova
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
GridView
Asked by
John
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
John
Top achievements
Rank 1
Share this question
or