Questions about grouping in flexgrid

Posted by: lars.seehaus on 31 August 2021, 6:02 pm EST

  • Posted 31 August 2021, 6:02 pm EST

    Hello,

    i have taken a look in grouping row in a flexgrid and have qeustion about it.

    I load table from the databse in the flexgrid that has a row for the year with some data in it and x rows for the months (can be 12 or less). I want to collapse and expand the month rows with the year row as the header. is there a way that is possible.

    If my explanation is to bad please let me know and sorry for my bad english

    Best regards

    Lars

  • Posted 31 August 2021, 8:12 pm EST

    Hi Lars,

    do you use databinding or do you fill the grid yourself?

    Did you see this article? https://www.grapecity.com/componentone/docs/win/online-flexgrid/grouping.html

    It describes your requirement. But your data needs a special column for the year. If you use databinding, the sql query should be modified so that year and month are in different columns.

    Hope this helps

    Wolfgang

  • Posted 1 September 2021, 9:51 pm EST

    Hello Lars,

    As per your explanation, ideally, your data needs a special column for the year on which it can be grouped as suggested by @Wolfgang.

    You can also perform Node operation to add the extra rows as given in the following documentation post

    https://www.grapecity.com/componentone/docs/win/online-flexgrid/tree-grid.html

    @Wolfgang, thank you for your suggestion.

    If you still face the issue, please share some screenshots or dummy data to explain your requirement to create a demo sample accordingly.

    Regards,

    Prabhat Sharma.

  • Posted 2 September 2021, 6:32 pm EST

    I have takne the code from the lint that wolfgang posted, but i have face a issue by this part```

    c1flex_JahresBlatt.GroupDescriptions = new List<C1.Win.C1FlexGrid.GroupDescription>(){​​​​​​​​new C1.Win.C1FlexGrid.GroupDescription(“Jahr”) }​​​​​​​​;

    When i compiled I get the error unexpected character an this 16 times.
  • Posted 2 September 2021, 9:41 pm EST

    Hello Lars,

    We do not face the issue at our end as shown in the attached screenshot. If you’re doing anything else then please let us know and modify the sample accordingly.

    Regards,

    Prabhat Sharma.

    GroupDescriptionDemo.zip

  • Posted 5 September 2021, 10:15 pm EST

    Hi,

    The Programm in the Zip is not finished.

    And does this work with c1flexgrid from version 4?

  • Posted 6 September 2021, 4:47 pm EST

    Hi,

    >>The program in the Zip is not finished.

    Sorry, we did not get it. Are you facing any issues while using the sample?

    >>And does this work with c1flexgrid from version 4?

    Yes, it will work. Please remove the 4.5.2 references and add the 4.0 Builds. Also, update the content of the License.licx file accordingly.

    If you still face any issues, please let us know and share the screenshot.

    Regards,

    Prabhat Sharma.

  • Posted 6 September 2021, 5:48 pm EST

    In my folder it is missing the Program.cs Class. Since the importatant part is only one line I have not seen I on the first reading.

    thanks for the reply

    Edit

    After I spoke with a colleague.

    We could fix it.

  • Posted 6 September 2021, 6:42 pm EST

    As it is working I have some more questions. Is it possible to allow the user to write in the cell of the column x in the header row of the group? And is there an easy why to save the data of the header row?

    Regards,

    Lars Seehaus

  • Posted 7 September 2021, 8:47 pm EST

    Hello,

    >>Is it possible to allow the user to write in the cell of the column x in the header row of the group?

    Sorry but the grouped node rows are non-editable, and it is not possible to allow the user to write in it.

    >>Is there an easy why to save the data of the header row?

    Here is the code snippet to save the header data into a list:

    List<string> groupList = new List<string>();
     String groupFormat = c1FlexGrid1.GroupHeaderFormat;
     c1FlexGrid1.GroupHeaderFormat = "{value}";
     for (int i = 1; i < c1FlexGrid1.Rows.Count - 1; i++)
     {
     if (c1FlexGrid1.Rows[i].IsNode)
     {
     Node row = c1FlexGrid1.Rows[i].Node as Node;
     groupList.Add(row.Data.ToString());
     Console.WriteLine(row.Data);
     c1FlexGrid1.Rows[i].AllowEditing = true;
     }
     }
     c1FlexGrid1.GroupHeaderFormat = groupFormat;
    

    Is there any specific format in which you want to save the data?

    Regards,

    Prabhat Sharma.

  • Posted 27 September 2021, 8:41 pm EST

    Thanks for the answer.

    I found a way to write in the node row.

    I save the data of the row in the Datatable that is the Data source of the flexgrid.

    I use a row for it, in that I copy the data of the node.

    If it is not possible to connect this row to the node row then I will use the loop that I already have.

    Regards

    Lars

  • Posted 28 September 2021, 8:04 pm EST

    Hello Lars,

    It is good to hear that you have found a way to tackle your scenario.

    You can go through the following documentation to learn how to perform node operations:

    https://www.grapecity.com/componentone/docs/win/online-flexgrid/node-operations.html

    Regards,

    Prabhat Sharma.

Need extra support?

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

Learn More

Forum Channels