Sorting getting enabled on header click

Posted by: sdayal on 14 September 2021, 8:20 pm EST

    • Post Options:
    • Link

    Posted 14 September 2021, 8:20 pm EST - Updated 3 October 2022, 3:30 am EST

    Hi team,

    Below solution was provided for disabling the sorting on header click.

     grid.hostElement.addEventListener(
          'click',
          e => {
            if (e.target.classList.contains('wj-state-active')) {
              grid.startEditing();
              var selection = window.getSelection();
              selection.collapseToEnd();
            }
    
            let ht = grid.hitTest(e);
            if (
              e.target.classList.contains('wj-header') &&
              ht.cellType == wjGrid.CellType.ColumnHeader
            ) {
              e.preventDefault();
              e.stopImmediatePropagation();
            }
          },
          true
        );
    

    Refer line ( 301 to 320)

    Snippet :- https://stackblitz.com/edit/angular-wcumux?file=src/app/app.component.ts

    But if you see in the gif attached below even though we have disabled sorting on header click but if we continuously click on the header it gets sorted and this behavior is more prominent in our case because as we navigate from different pages we end up getting sorting done by header click .

    How can we remove sorting from header ?

    PS: Sorting should only be done using the sorting icon provided.

    Please provide solution.

    Regards.

  • Posted 15 September 2021, 3:07 pm EST

    Hi team,

    Can you please provide solution for this.

    Regards

  • Posted 15 September 2021, 3:35 pm EST

    Hello,

    As per the observation, the sorting on clicking the column header occurred when we click on the mandatory-symbol, I have updated the sample to only work on the sorting buttons. Please refer to the updated sample link below:

    https://stackblitz.com/edit/angular-4imrs9?file=src/app/app.component.ts

    Let us know if you face any issues.

    Regards

Need extra support?

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

Learn More

Forum Channels