DataGrid: changing ItemSources data when Grouping large datasets

Posted by: chuck.greely on 26 April 2019, 2:39 am EST

  • Posted 26 April 2019, 2:39 am EST

    Hello,

    I have a dataset that has over 50,000 records retrieved through a REST API call. The records become rows in a DataGrid. Many of the column values require converters on them. In order to make things more efficient and not having to load all 50,000 rows, I load the DataGrid with 100 rows. The user clicks a ‘next’ button and I retrieve the next hundred rows, etc… This works fine.

    When I want to Group the data, only the 100 rows currently assigned to the DataGrid.Itemsource property are grouped. I would like to have the Grouping retrieve the full 50,000 records and assign them to the DataGrid.Itemsource property and then Group on them. I tried using the MyDataGrid_GroupChanging event but this is fired after the grouping of the current 100 rows is executed.

    Do you have any code examples that answer the following questions:

    1.) What event do I put my data access code that will retrieve the 50,000 records and then assign it to MyDataGrid.ItemSource property so that the 50,000 rows are grouped and not the currently displayed 100 rows? What event is fired when you drag a column header into the grouping area?

    2.) Since these Grouped sections have thousands of rows to each group, I don’t want to load them all. Instead, when the user clicks the header to expand to see the rows that make up the group, I’d like to load another subgrid (DataGrid? FlexGrid?) where only 50 rows are displayed and paging to the next/previous pages can occur.

    Thanks very much,

    Dave

  • Posted 28 April 2019, 9:25 pm EST

    Hi Dave,

    1. You can use C1DataGrid’s ColumnHeaderDragStarted event for detecting when a column drag starts.
    2. To show another subgrid, you can set C1DataGrird’s RowDetailsTemplate and set it to another C1DataGrid instance. We even have a product sample that illustrates this [Under ‘Hierarchical’ tab]. So, you’re suggested to refer the same.

      You can set the subgrid’s ItemsSource only at the time of expanding the master row, to prevent loading them all.

    Thanks,

    Ruchir

  • Posted 28 April 2019, 11:20 pm EST

    Ruchir,

    Thank you for the quick response. I appreciate it. I will give these a try.

    Dave

  • Posted 30 April 2019, 1:35 am EST

    Hi Ruchir,

    The ColumnHeaderDraggedStart event you mentioned was helpful. Thanks for that info.

    The ‘Hierarchical’ tab in your demo unfortunately does not help me with the bigger issue I have. That demo uses a predefined Main Grid and in the RowDetailsTemplate defines a subgrid. When the demo page is loaded, it shows a header row and as you scroll downward it displays a subgrid of data supporting the header row. It doesn’t load all the records originally in the main grid and then allow the user to group by one or many columns, then showing the headers only with the ability to click the header and THEN load the detailed subgrid data.

    To understand what I’m trying to do, look at the first tab in your example, the ‘demo’ tab. It lists rows of data. You can then group the data by one or many columns. What I’d like to do is when the grouping occurs, I’d like to show JUST the header rows (with some summary numerical data) and when the user clicks the header, I THEN want to call the datastore and retrieve the supporting rows and display them in a new subgrid.

    Is there a way to have the main grid display just the header rows with no supporting data displayed with it (because I don’t want the overhead of 50,000 rows of data to be retrieved)? Then when I click the header I fetch the supporting data for that row?

    If you have any code examples for that I would greatly appreciate it.

    Dave

  • Posted 30 April 2019, 10:58 pm EST

    Hi Dave,

    Sorry but there are no existing codes for this.

    So, I am discussing your requirement with the developers and will get back to you once we receive some information [ID:377119].

    Thanks,

    Ruchir

  • Posted 1 May 2019, 11:34 pm EST

    Hi Ruchir,

    Ok, thanks for the update. I will be waiting to hear back from you.

    Thank you.

    Dave

  • Posted 8 May 2019, 12:27 am EST

    Hi Ruchir,

    Any update on this? Waiting to hear back from you about your developers’ further response.

    Thank you.

    Dave

  • Posted 9 May 2019, 9:32 pm EST

    Hi Dave,

    Sorry for the delay in response. However, Developer provided the following responses for your scenarios:

    >> Grouping need to retrieve the full 50,000 records and assign them to the DataGrid.Itemsource property and then Group them.



    We have no good way to get a big amount of data to the app and still keep the performance because of lack of memory, need too much time to get data through the network etc.

    So, If you get the data from the server, please get the row by group instead of random order. For example, you can get 2 group of items each time.

    >> After grouping, grid should show only the group rows (no child rows retrieved). When the group row is expanded, then only retrieve the data for its child rows and show them in child rows.

    Instead of calculating data at the app, you should calculate each chunk of data at server before fetching it to client. For example, calculate the parent group at server, fetch it from server and if you want to see the detail, you can get it later.

    Meanwhile, I am trying to create a sample to perform all this and will get back here as soon as it’s done.

    Thanks & Regards,

    Basant

  • Posted 13 May 2019, 11:30 pm EST

    Hi Dave,

    Considering your implementation requirements all together with the implementation suggested by the developers, I would like you to know the following:

    Since you want to show the child rows for a group in a sub grid which implies mixing the Grouping feature with the DetailRow feature of a grid. Whereas these two features are mutually exclusive in terms of their use and implementation so we can’t use DetailRow for showing child rows of a group.

    So, we are sorry to inform you that your requirements can not be implemented in the way specified. However, can you please share your use case so that, if possible, we can think for an alternative approach?

    Thanks,

    Basant

  • Posted 16 May 2019, 4:49 am EST

    Hi Basant,

    Thank you for your response and for taking the time to look into this. I’m narrowing the requirements down a bit so I can approach this a little bit differently. Here’s where I’m at now.

    When a user chooses to group by a certain column, in the GroupChanging event I am making a call to the database server, executing a sql statement that gives me a list of strings that represent the group header information. I’m not returning any detail data at this time.

    I want to be able to take the list of string data that I retrieve and have each string become a group header row, with no detail data under it. Then I will setup an event firing when the user clicks (+/-) to expand the header and will show a subgrid that will go off to the server and fetch the detailed records for that header row and display it in the subgrid. Do you have any code examples that show how to assign a string of text and turn it into a group header row? Or even a list of strings turned into many group header rows? I’ve seen some code on showing how to SUM() and COUNT() and put this data in the group header row but the detail rows are still there. I simply want to have nothing but header rows created from a list of strings.

    Thanks again for your assistance. I appreciate it.

    Dave

  • Posted 19 May 2019, 6:30 pm EST

    Hi Dave,

    We understood your requirements and reached at the following reasoning:

    1. DataGrid/FlexGrid uses CollectionView for grouping/sorting/filtering data items. However, It won’t be possible to use a List of string(group header names) for grid to generate groups while keeping the original column structure.

    2. Since you want the details for a group to be presented in a sub grid so this way of implementation would require the use of DetailRow. Whereas, again, the DetailRow can not be used for implementing Grouping in a grid. So, this can’t be implemented using the grouping facility provided by DataGrid/FlexGrid.

    We are sorry for the inconvenience caused.

    Regards,

    Basant

Need extra support?

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

Learn More

Forum Channels