1

I am using a RadGridView to display data to users. I had added a Check All checkbox control to enable uses to select all records. For this matter, I have used EventTrigger and it's working just fine. but recently I have noticed that CheckAll would select prior pages' items displayed on RadGridView previously which might cause unfavorable behavior to users. Any idea why is this happening? Any way to disable caching?

<telerik:RadGridView ItemsSource="{Binding DataContext.ListDataView, Mode=OneWay, UpdateSourceTrigger=PropertyChanged, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}}">
                <i:Interaction.Behaviors>
                    <behav:PagedGridViewBehavior />
                <telerik:RadGridView.Columns>
                    <telerik:GridViewDataColumn IsCustomSortingEnabled="False"
                                                IsSortable="False">
                        <telerik:GridViewDataColumn.Header>
                            <CheckBox Name="chkCheckAll"
                                      IsChecked="{Binding DataContext.IsAllChecked, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}}" />
                        </telerik:GridViewDataColumn.Header>
                        <telerik:GridViewDataColumn.CellTemplate>
                            <DataTemplate>
                                <CheckBox IsChecked="{Binding DataContext.IsAllChecked, Mode=OneWay, UpdateSourceTrigger=PropertyChanged, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}}">
                                    <i:Interaction.Triggers>
                                        <i:EventTrigger EventName="Checked">
                                            <i:InvokeCommandAction Command="{Binding DataContext.ReleaseCheckedCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}}"
                                                                   CommandParameter="{Binding REL_NO}" />
                                        </i:EventTrigger>
                                        <i:EventTrigger EventName="Unchecked">
                                            <i:InvokeCommandAction Command="{Binding DataContext.ReleaseUncheckedCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}}"
                                                                   CommandParameter="{Binding REL_NO}" />
                                        </i:EventTrigger>
                                    </i:Interaction.Triggers>
                                </CheckBox>
                            </DataTemplate>
                        </telerik:GridViewDataColumn.CellTemplate>
                    </telerik:GridViewDataColumn>
    </telerik:RadGridView.Columns>
</telerik:RadGridView>

Thanks

Abdulkarim Kanaan
  • 1,703
  • 4
  • 20
  • 32
  • What exactly is happening and what are you expecting? – mm8 Jan 16 '18 at 10:15
  • @mm8 simply the issue is when I click on "Check All" button to select all the current-page items displayed on the RadGridView, items from prior displayed items (from other pages) will fire the EventTrigger too, I suspect that RadGridView does some caching. – Abdulkarim Kanaan Jan 18 '18 at 06:08
  • It's probably because all UserControls share the same DataContext, i.e. a shared instance of the class where the IsAllChecked property is defined. – mm8 Jan 19 '18 at 12:35
  • @mm8 thanks. Maybe I didn't explain well in terms of 'other pages'. I meant I am using paging in RadGridView - it's a single control. Let's say RadGridView has loaded Page'1'. When click on 'CheckAll' button while I am in page'2'; the bound keys (REL_NO) from Page'1' were shown as well. I hope now it's clearer – Abdulkarim Kanaan Jan 19 '18 at 15:23
  • You are still binding to the same property... – mm8 Jan 19 '18 at 15:29

0 Answers0