Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
50
I urge you to implement SelectAllRecords command
posted

Hello, as I have seen in many posts and a main post (https://www.infragistics.com/community/forums/p/69167/353123.aspx) where a user needs a way to select all records, (with ex. CTRL+A) while doing this with the shift key is vey quick, if its done by code by changing all records with Record.IsSelected = True to all records, it is REALLY slow. I urge you to make a command to make this quickly. In a list with 13.000 records I closed down my test app because I got tired waiting, but with selecting the first record and then the last with the shift key, eveything is selected in less than a second.

You have not offered a viable solution for this problem, even when so many years have passed since someone initially noticed it.

Thank you

  • 6365
    Verified Answer
    Offline posted

    Hello Chris,

    Thank you for the thread reference you have provided.

    I have tested the selection behavior you have described, along with the information from the referenced thread and I can suggest you to use the SelectedItems property of the XamDataGrid for selecting all records by populating the SelectedItems.Records respectively.

    This can be done within a Command for Control + A key binding, for example:

    XAML:

    <igDP:XamDataGrid.InputBindings>
        <KeyBinding Key="A" Modifiers="Control" CommandParameter="{Binding ElementName=dataGrid}">
            <KeyBinding.Command>
                <local:SelectAllCommand />
            </KeyBinding.Command>
        </KeyBinding>
    </igDP:XamDataGrid.InputBindings>

    Code-behind:

    public class SelectAllCommand : ICommand
    {
        public event EventHandler CanExecuteChanged;
        public bool CanExecute(object parameter)
        {
            return true;
        }
        public void Execute(object parameter)
        {
            var grid = (parameter as XamDataGrid);
            grid.SelectedItems.Records.AddRange(grid.Records.ToArray());
        }
    }

    Another approach would be to execute the same code in a button click

    private void Button_Click(object sender, RoutedEventArgs e)
    {
        dataGrid.SelectedItems.Records.AddRange(dataGrid.Records.ToArray());
    }

    I have attached a sample application that demonstrates the approach from above by using 20,000 records.

    If you have any questions, please let me know.

    XamDataGrid_sample.zip