Update another cell using CreateCellEditElement in current cell

4 posts, 0 answers
  1. Stavros
    Stavros avatar
    4 posts
    Member since:
    Jun 2014

    Posted 10 Oct Link to this post

    Hello, lets say that we are using the radGridView and we have some columns like above:

    First Name, Last Name, Sex, Age, Type1, Type2

    The column "Type1" has a custom editor that implements the classes:

    CreateCellElement and CreateCellEditElement using a combobox for selection of value.

    Also i must clarify that column "Type2" depents on column's "Type1" value

    So how can we clear in the current row the column's "Type2" value when the value of column "Type1" is changed through the CreateCellEditElement?

     

    Thanks

  2. Stefan Nenchev
    Admin
    Stefan Nenchev avatar
    280 posts

    Posted 11 Oct Link to this post

    Hi Stavros,

    I am not fully familiar with your specific setup, but generally, in the scenario you have explained, you can call PropertyChanged of Type2 in the setter of Type1. This way, when you have set the value of Type1, the value of Type2 will be updated in the RadGridView. I have attached a sample project for your reference. It does not use a custom column but the approach should be the same for you. Please check the "Club" object implementation. 

    Regards,
    Stefan Nenchev
    Telerik by Progress
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Stavros
    Stavros avatar
    4 posts
    Member since:
    Jun 2014

    Posted 11 Oct in reply to Stefan Nenchev Link to this post

    Nice, this does do the job, when i change the value of column's "Type1" and focus somewhere else, the onrowedit event is fired and the value of column's "Type2" is cleared.

    Now i am thinking something more complex in the above implementation, to do it more dunamically.

    Is possible to clear column's "Type2" value when the selected index of combobox of custom editor of column's "Type1" is changing before onrowedit is fired?

  5. Stefan Nenchev
    Admin
    Stefan Nenchev avatar
    280 posts

    Posted 13 Oct Link to this post

    Hello Stavros, 

    As far as I understand your requirement, you would like to change the value of the second property when the selection is changed in the RadComboBox. Is this correct?

    If this is the case, you can attach to the SelectionChanged event of the RadComboBox and call CommitEdit on the RadGridView:

    public MainWindow()
           {
               InitializeComponent();
               this.AddHandler(RadComboBox.SelectionChangedEvent, new SelectionChangedEventHandler(onSelectionChanged));
           }
     
    private void onSelectionChanged(object sender, SelectionChangedEventArgs e)
           {
               if (e.RemovedItems.Count > 0)
               {
                   this.pilotsGrid.CommitEdit();
               }
           }

    I have added another sample that reflects your setup more precisely. 

    Regards,
    Stefan Nenchev
    Telerik by Progress
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Back to Top