Prevent selected-index-changed-event for a custom-cell to fire until after all data has loaded.

1 Answer 12 Views
GridView
Oliver
Top achievements
Rank 1
Oliver asked on 25 Mar 2024, 09:45 AM

 

Hello,

I've created a custom cell in a radgridview so that I can in one column either display a RadDropDownListElement or a RadTextBoxControlElement depending on if the tag of the row has a datatable or not. If it has a datatable it will show the dropdown, otherwise it shows the textbox.

This I've done pretty much according to this tutorial.

https://docs.telerik.com/devtools/winforms/controls/gridview/cells/creating-custom-cells#custom-group-cell-example

 

However, my problem is that the selected index changed event on the dropdown is triggered too early, i.e. before all data has been loaded. Is there a way to get around this? I would like that the selected index changed event only kicked in if all the data of the form has been loaded. This I usually achieve by checking if a flag, e.g. 'IsInitiated', is true in the  beginning of the Sub. But cannot seem to reach such a flag from the custom cell class.

 

1 Answer, 1 is accepted

Sort by
0
Nadya | Tech Support Engineer
Telerik team
answered on 28 Mar 2024, 07:44 AM

Hello, Oliver,

Thank you for writing.

RadDropDownListElement offers ListElement property which has DataBindingComplete event. This event fires when the binding operation has finished. I can suggest using the DataBindingComplete event by raising a flag, e.g "IsInitiated" and later check the flag in the SelectedIndexChanged event. Please refer to the following example:

this.combo = new RadDropDownListElement();
this.combo.SelectedIndexChanged += Combo_SelectedIndexChanged;
this.combo.ListElement.DataBindingComplete += ListElement_DataBindingComplete;
//...

bool IsInitiated = false;
private void ListElement_DataBindingComplete(object sender, ListBindingCompleteEventArgs e)
{
   IsInitiated = true;
}

private void Combo_SelectedIndexChanged(object sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e)
{
    if (IsInitiated)
    {
        IsInitiated = false;
        return;
    }
    // TO DO
}

I hope this helps. If you have other questions, please let me know. 

Regards,
Nadya | Tech Support Engineer
Progress Telerik

A brand new ThemeBuilder course was just added to the Virtual Classroom. The training course was designed to help you get started with ThemeBuilder for styling Telerik and Kendo UI components for your applications. You can check it out at https://learn.telerik.com
Tags
GridView
Asked by
Oliver
Top achievements
Rank 1
Answers by
Nadya | Tech Support Engineer
Telerik team
Share this question
or