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

DataLoaded timing?

1 Answer 71 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Nathan
Top achievements
Rank 2
Nathan asked on 27 May 2010, 06:59 PM
Hey,

I'm having some trouble with a Telerik RadGridView where I want to be able to tell if the user clicked a checkbox vs. it being set via the binding. This is so I can set a "dirty" status and let them know they have made changes that require saving.

My first approach:
1) Set a loading=true flag when I'm about to bind to my collection of objects
2) Set loading=false in the DataLoaded event
3) on checkbox_checked event, as long as loading=false it is the user, not a binding causing the change in value
This approach did not work. I get the DataLoaded event, and then a short while later I get the checkbox_checked event for any rows that are bound to a "true" value. Is there a reason DataLoaded fires before the checkboxes get checked? I assumed DataLoaded would only fire once all binding/setting of values was complete. Note that I have turned on/off IsSynchronizedWithCurrentItem, and also made sure DataLoadMode is Synchronous.

The second approach was to try to trap a mouseup/down event on the checkbox itself, as that way I know it's the user, not a binding changing the value. Unfortunately I do not receive these mouse events (I assume they are gobbled up by the grid?)

Here is the declaration of the Grid in case you can spot a mistake I am making:
<telerikGridView:RadGridView x:Name="dgUserPrefs"   
                    DataLoadMode="Synchronous"   
                    ColumnWidth="*"   
                    AutoGenerateColumns="False" 
                    ShowGroupPanel="False"    
                    IsFilteringAllowed="False"   
                    IsReadOnly="True" 
                    HorizontalAlignment="Stretch" 
                    CanUserReorderColumns="False"   
                    CanUserSortColumns="False"   
                    CanUserSelect="True" 
                    CanUserResizeColumns="False"   
                                  RowIndicatorVisibility="Collapsed"    
                                         Margin="3" 
                                         IsSynchronizedWithCurrentItem="False" 
                                > 
                <telerikGridView:RadGridView.Columns> 
                    <telerikGridView:GridViewDataColumn Header="Shift Type" DataMemberBinding="{Binding SHIFT_TYPE_DESC}" UniqueName="Shift Type"></telerikGridView:GridViewDataColumn> 
                    <telerikGridView:GridViewDataColumn Header="Preference" UniqueName="Preference" HeaderTextAlignment="Center" 
                        <telerikGridView:GridViewDataColumn.CellTemplate> 
                            <DataTemplate> 
                                <CheckBox x:Name="chBoxPriority"   
                                     IsChecked="{Binding PRIORITY, Mode=TwoWay}" 
                                          Checked="chBoxPriority_Checked" 
                                          MouseLeftButtonDown="chBoxPriority_MouseLeftButtonDown" 
                                      HorizontalAlignment="Center"/>  
                            </DataTemplate> 
                        </telerikGridView:GridViewDataColumn.CellTemplate> 
                    </telerikGridView:GridViewDataColumn> 
                </telerikGridView:RadGridView.Columns> 
            </telerikGridView:RadGridView> 

Any help on this would be appreciated!

Nathan

1 Answer, 1 is accepted

Sort by
0
Accepted
Milan
Telerik team
answered on 28 May 2010, 07:14 AM
Hi Nathan Riske,

You could try to use the CLick event:

<telerik:GridViewDataColumn Header="Preference" UniqueName="Preference" HeaderTextAlignment="Center">
    <telerik:GridViewDataColumn.CellTemplate>
        <DataTemplate>
            <CheckBox x:Name="chBoxPriority"   
                     IsChecked="{Binding Checked, Mode=TwoWay}" 
                     Click="chBoxPriority_Click"
                      HorizontalAlignment="Center"/>
        </DataTemplate>
    </telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>


Kind regards,
Milan
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
Nathan
Top achievements
Rank 2
Answers by
Milan
Telerik team
Share this question
or