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

CheckBox firing event on load

2 Answers 449 Views
GridView
This is a migrated thread and some comments may be shown as answers.
James DAmour
Top achievements
Rank 1
James DAmour asked on 23 Jan 2019, 12:04 AM

I'm trying to have a checkbox as a column that fires an event when it is checked or unchecked. The current code does that, but the problem I am facing is that when the grid is loading, it is firing an event for each item in the grid before it displays. Is there a way around this?

                            <telerik:GridViewDataColumn Header="" DataMemberBinding="{Binding IsCheckedInModel, Mode=TwoWay}" >
                                <telerik:GridViewDataColumn.CellTemplate>
                                    <DataTemplate>
                                        <CheckBox IsChecked="{Binding IsCheckedInModel, Mode=TwoWay}" Checked="VarImportance_Checked" Unchecked="VarImportance_Checked"/>
                                    </DataTemplate>
                                </telerik:GridViewDataColumn.CellTemplate>
                            </telerik:GridViewDataColumn>

Thanks,

Nelson

2 Answers, 1 is accepted

Sort by
0
Accepted
Dinko
Telerik team
answered on 25 Jan 2019, 01:49 PM
Hello James,

Upon checking on my side, If internally in the code the IsCheckedInModel is set to true for an item, the CheckBox -> Checked event will be fired. I am not aware of an approach to prevent the Checked method to be called. This is framework specific. What comes up to my mind is to check if the RadGridView is loaded by using IsLoaded property.
private void VarImportance_Checked(object sender, RoutedEventArgs e)
{
    if(this.gridView.IsLoaded)
    {
        // executed your code
    }
}

Hope this approach will work on your side.

Regards,
Dinko
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
James DAmour
Top achievements
Rank 1
answered on 25 Jan 2019, 06:05 PM

Hi Dinko,

Thanks for the response. Unfortunately I had already tried that and the checkboxes initialize after the grid is loaded. Anyway, I'll try some other workaround.

Regards,

James

Tags
GridView
Asked by
James DAmour
Top achievements
Rank 1
Answers by
Dinko
Telerik team
James DAmour
Top achievements
Rank 1
Share this question
or