Appending records to a grouped grid wipes out grouping

Posted by: david.mcdonald on 5 May 2020, 11:05 pm EST

    • Post Options:
    • Link

    Posted 5 May 2020, 11:05 pm EST

    Hello,

    I have a dataset that has over 500,000 records. I only load 100 at a time in the grid. When I choose a column to group on, I make a call to the database that will give me purposely only 1 record for each group.

    When I click the “+” to expand the group header row, I call an event named GrpRow_GroupRowsVisibilityChanged where I then capture information about the header row and pass that information to the database to retrieve records that match that grouping.

    After I retrieve the records from the database, I assign them to a ListControlView and then assign the ListControlView to the ItemsSource property of the grid. This ends up displaying a grid with no grouping and only having the rows that I just retrieved from the database.

    Is there a way to append additional rows to the grid without it wiping out all the other rows and the grouped rows as well? Do I have to first capture the state of the grid, meaning all the grouping info, the sorting and filtering info and all the data and then append the new records to the grid and reapply the grouping, sorting and filtering info again programmatically? Seems there should be an easier way to append rows without having to recreate the whole state of the grid every time.

    Please clarify and provide any code samples if possible.

    Thank you very much.

    Dave

  • Posted 7 May 2020, 2:40 am EST

    Hi Dave,

    Assigning the ItemsSource property of the grid, resets all existing information/settings. So, the grouping getting wiped off is correct and by-design.

    Also, you are correct that in order to meet your requirement you need to save grid information and after setting its ItemsSource, reload the saved information in grid.

    To help you with saving grid information, please refer the blog: https://www.grapecity.com/blogs/how-to-save-the-state-of-c1datagrid

    Regards,

    Ruchir

  • Posted 11 May 2020, 5:01 am EST

    Hello Ruchir,

    Thanks for the info. I will have a look at the link your provided.

    Have a nice day.

    Dave

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels