C1FlexGrid: grouping and sorting/filtering

Posted by: wknauf on 2 October 2020, 2:57 am EST

  • Posted 2 October 2020, 2:57 am EST

    Hi C1,

    after using C1FlexGrid grouping for the first time, there are two questions/problems:

    a) it is not possible to sort columns.
    If column sorting is enabled, a crash will occur on click:

    Message: Die Liste hatte eine feste Größe.

    bei System.SZArrayHelper.Add[T](T value)
    bei C1.Win.C1FlexGrid.C1FlexGridBase.Sort(SortFlags order, Int32 col1, Int32 col2)
    bei C1.Win.C1FlexGrid.C1FlexGridBase.#6jh(Int32 #4O)
    bei #y9g.#brh.#Jqh(MouseEventArgs #9l)
    bei C1.Win.C1FlexGrid.C1FlexGridBase.OnMouseUp(MouseEventArgs e)
    bei System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
    bei System.Windows.Forms.Control.WndProc(Message& m)
    bei C1.Win.C1FlexGrid.Util.BaseControls.ScrollableControl.WndProc(Message& m)
    bei C1.Win.C1FlexGrid.C1FlexGridBase.WndProc(Message& m)
    bei System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

    (the message translates to something like "list has a fixed size").

    I don't know whether sorting is possible/defined anyway. You might sort only the items inside of each group, or you might even sort the groups by the sort order of the first item of each group. We use the mode "HideGroupedColumns = true", so there is no grouping column visible which could be used to sort the groups.
    But at least a better error message should be shown, e.g. "Sorting is not possible when grouping".

    b) when AllowFilterung is true, you can set a filter so that empty groups are shown. Would it be possible to hide those rows without visible childs?

    Probably this is possible when handling the "AfterFilter" event, but I would prefer if this would be part of the C1FlexGrid core code ;-).

    I am on vacation next week, so don't expect a quick reply of mine.

    Best regards

  • Replied 5 October 2020, 7:53 pm EST


    1: I can’t replicate the issue at my end. When the grid has grouping, sorting on click is disabled.

    2: Yes, AfterFilter can be used to hide those rows by using the HasVisibleChildren property of a node. A sample is attached for reference, please have a look and let me know if this helps.

    Prabhat Sharma.
  • Replied 11 October 2020, 9:35 pm EST

    Hi Prabhat,

    1: attached sample reprocudes the crash: click on the header labeled "Data" and the crash will occur.
    I can workaround by setting "AllowSorting = false", but as I used the default settings here, I would expect a more meaningful exception (e.g. "Sorting is not supported in grouped grid") so that the developer knows better how to fix this.

    2: thanks a lot! Maybe you (or the developers) could think about adding this feature to the core grid? Or is the request to exotic ;-)?

    Best regards

  • Replied 12 October 2020, 6:52 pm EST


    1: Thank you for the sample. It seems that the issue occurs when using the grid in unbound mode. We have escalated this to the developers and will let you know once we get any update on this from their end.
    [Internal Tracking ID: 466999]

    2: We have forwarded this to the developers as an enhancement request and will let you know once we get any update on this from their end.
    [Internal Tracking ID: 467001]

    Prabhat Sharma.
  • Replied 24 November 2020, 10:09 pm EST

    Hello Wolfgang,

    As per the decvs, you need to use a non-fixed collection like List because IList.IsFixedSize = true which leads to an exception when trying to change GroupDescriptions.
    Please change the following code in your sample to resolve this issue:


    this.c1FlexGrid1.GroupDescriptions = new C1.Win.C1FlexGrid.GroupDescription[] { new C1.Win.C1FlexGrid.GroupDescription(COL_GROUPING, null) };


    this.c1FlexGrid1.GroupDescriptions = new List<C1.Win.C1FlexGrid.GroupDescription> { new C1.Win.C1FlexGrid.GroupDescription(COL_GROUPING, null) };

    Prabhat Sharma.
  • Replied 25 November 2020, 12:01 am EST

    Damn, you are right - sorting works now ;-). But I am not sure whether the result is helpful, as all items in the grid are sorted and afterwards grouping is applied. So you might have a lot of groups with only one item, because a large group can be split to a lot of smaller groups.
    But at least the crash is "fixed" - and maybe this helps others.

    Could you modify the docs? I found two places which suggest the array:

    Many thanks!

  • Replied 25 November 2020, 9:07 pm EST

    Hi Wolfgang,

    It is good to hear that it is working at your end. If you face any issues with its behavior then please let us know.

    We have forwarded the request to the documentation team and it will be updated soon.

    Prabhat Sharma.
Need extra support?

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

Learn More

Forum Channels