FlexGrid - Programmatic click not setting selection

Posted by: craig.daniel on 8 August 2023, 2:03 am EST

  • Posted 8 August 2023, 2:03 am EST

    I am creating an angular unit test and want to test selection and binding function as expected.

    The gird has row selection (ie [selectionMode]=“3”) and a grid click event which then performs some actions based on the selection.

    In the unit test I invoke the click event, and the handler fires, but the grid has nothing selected.

  • Posted 8 August 2023, 8:02 pm EST

    Hi,

    In FlexGrid to change the selection simply invoking a click event wouldn’t work as it requires other events like mousedown, mouseup as well in its defined sequence. Therefore to change the selection you may use the select() method of FlexGrid and pass the row and column indexes of the cell you want to get selected(make active cell).

    You can use this method in the angular unit test to change the selection dynamically through code and check the ‘wj-state-selected’ class of that cell to verify the selection change. Please refer to the sample link below for implementation:

    Sample: FlexGrid_Angular_Test_Sample.zip

    Regards

  • Posted 10 August 2023, 7:44 pm EST

    Thanks, but I want to test with the grid setting the selection as I am testing with the grid wired up.

    I have tried dispatching events for mousedown, mouseup and then click, but with no success.

  • Posted 13 August 2023, 7:51 pm EST

    Hello,

    Sorry for the confusion. In that case, you can create a MouseEvent for ‘mousedown’ and pass the x and y coordinates of the cell element and then dispatch that event on cell element. Please refer to the updated sample attached below demonstrating the same:

    Sample: FlexGrid_Angular_Test_Sample_Updated.zip

    Regards

  • Posted 15 January 2024, 2:07 am EST

    Hi,

    Following your advice I dispatched

    mouseover

    mousedown

    mouseup

    click

    events and all worked as expected.

    However I have just updated to the latest version (5.20232.939) and this no longer works.

    At the point of the click event being raised from the grid the selectedRows property of the grid is no longer set.

  • Posted 15 January 2024, 5:25 pm EST

    Hello,

    We apologize but we are unable to replicate the issue at our end, could you please refer to the below sample used to replicate the issue and let us know if any changes are required to replicate the issue at our end?

    If you are facing the issue only in your application and not in the below-shared sample, it might be possible that the issue is caused due to some other factors in your application therefore I would request you to please share a small sample replicating the issue along with the exact wijmo version.

    Sample: Wijmo_Angular_Test_Sample.zip

    Please refer to the “grid.component.spec.ts” file for the specific test case used to check selectedRows count when the click event is raised.

    Regards

Need extra support?

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

Learn More

Forum Channels