How to modify/prevent cell click event

Yousif Ahmed asked on March 12, 2019

Hi,
Is it possible to have some control over the cell click event? We have our own drag/drop functionality in our app and want to allow users to select cells and then drag that selection off the pivot. However, currently cells are selected by holding down the mouse and dragging, and the second click unselects the cells, it is difficult to integrate this functionality. Is there a way to either prevent the cell click event, or for example to only allow selection on shift-click? It looks as though the event handlers in the api do not give access to the event object itself?
 
Kind Regards,
 
Yousif

4 answers

Public
Tanya Gryshko Flexmonster March 12, 2019

Hello, Yousif,

Thank you for your interest in Flexmonster Pivot.

We would like to inform you that it is possible to copy the selected cells and paste them elsewhere. Could you please let us know if such option works for you?

Another way to handle the case is to use a combination of cellclick event and getSelectedCell method that returns information about the selected cell/cells. Here is an example:

flexmonster.on('cellclick', function (cell) {
console.log(flexmonster.getSelectedCell());
});

Such code allows getting information about which cells were selected. Then you can highlight these cells by applying custom styles or just use the information about them.

Please share your feedback.

Regards,
Tanya

Public
Dmytro Zvazhii Flexmonster March 13, 2019

Hello Yousif,
We have carefully checked your case one more time. Please find our suggestions below:
 

  • One of our suggestions is to replace drag n drop with the context menu approach. Please refer to our documentation: https://www.flexmonster.com/api/customizecontextmenu/. The idea is the following: you can still use Flexmonster’s selection and then with the help of right-click menu make certain manipulations to move the data further. Such an approach can be even more convenient since there is no need to drag the fields to the bottom of the screen. 
  • Currently, there is no option to intercept our click events outside the component. Flexmonster’s selection does not support such drag n drop. Our selection was created for solving different tasks. Therefore, you will need to implement such drag n drop functionality on your own. There is an option to disable the calculation bar and hide Flexmonster’s selection with CSS.

 
Please let us know in case you need more guidance from us.
Regards,
Dmytro

Public
Yousif Ahmed March 19, 2019

Hi Dmytro,
Thank you for your reply. I have found a workaround to dragging directly from the grid that I think will work for our cell selection. 
With regards to the getSelectedCell api method, it is great for getting data about the selection, but I cannot see a setSelectedCell method in the api reference – is there a way of clearing the selected cell collection directly via the api or otherwise?
 
Many thanks,
Yousif

Public
Vera Didenko Flexmonster March 19, 2019

Hello, Yousif,

We are glad you found a workaround which works well for you.

You are right, we don’t have a setSelectedCell method in the API reference.
However, we have a removeSelection API call which removes a selection from cells on the grid.
Hope this helps.

Please let us know if everything works for you and if you have further questions.

Best Regards,
Vera

Please login or Register to Submit Answer