Sort multiple columns in same order clicking 1 column on React Wijmo Flexgrid

Posted by: ozan.bilgic on 5 June 2023, 11:24 pm EST

    • Post Options:
    • Link

    Posted 5 June 2023, 11:24 pm EST - Updated 5 June 2023, 11:30 pm EST

    I use react wijmo flexgrid. I have groups on my sheet. Columns for these groups are not shown, so I am having a problem with sorting.

    When I click Name column, I want entityType group to be sorted in same order as well.

    flexgrid itemSource prop is source state and I use this way for grouping items:

     useEffect(() => {
        setSource(
          new CollectionView(wijmoData, {
            groupDescriptions: ['entityType', 'kind'],
            currentItem: null,
          })
        );
      }, [searchText, wijmoData]);

    Thanks.

  • Posted 6 June 2023, 9:31 pm EST

     flexgrid.collectionView.sortConverter = (
          sd: SortDescription,
          item: any,
          value: any
        ) => {
          if (sd.property === 'name') {
            return item.entityType + ' ' + item.kind + ' ' + value;
          }
        };

    Worked for me.

  • Posted 6 June 2023, 11:18 pm EST

    We are glad that you were able to resolve the issue on your own. Thank you for sharing the solution with us, it can potentially assist others who encounter similar issues.

    Regards

  • Posted 7 June 2023, 11:16 pm EST

    Hi I have one more question, 2. level group includes ‘Kind’. When I sort ‘Name’ column order of ‘Kind’ changes. But I always want Kind to be in the same order 1) Property and 2) NavigationProperty.

    Is it possible to achieve this?

  • Posted 8 June 2023, 11:37 pm EST

    Hello,

    As per our understanding, you want to only sort Column EntityType when the Name columnHeader is clicked, if so then you may remove the item.kind column sorting from sortConverter’s callback function. Please refer to the below code snippet and sample link for reference:

     flexgrid.collectionView.sortConverter = (
          sd: SortDescription,
          item: any,
          value: any
        ) => {
          if (sd.property === 'name') {
            return item.entityType + ' ' + value;
          }
        };

    https://stackblitz.com/edit/react-9akjet?file=Hello.js

    Regards

Need extra support?

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

Learn More

Forum Channels