I have a business requirement where certain fields with specific unique names must always be present in either rows or columns (at least in one of them). I'm looking for guidance on how to implement this validation.
Use Case:
We need to ensure that a specific field (e.g., a field with uniqueName "requiredField") is always displayed in the pivot table, either in rows or columns, and users should not be able to remove it completely from both areas.
Possible Approaches I'm Considering:
Pre-configure and Lock Field Position:
Validation on Field Removal:
Questions:
Hello, Taehong!
Thank you for your question.
Kindly note that it is not possible to prevent some fields from being removed from the slice using our built-in Field List control. For such use cases, we recommend creating your own Field List control.
Please find detailed answers to your questions below:
1) Is there a built-in way to mark certain fields as "required" in the pivot configuration?
In Flexmonster, it is not possible to set some fields as required out of the box.
2) Can we hook into events before a field is removed to validate and potentially cancel the action?
There are no Flexmonster events that are triggered on minor changes in the Field List. It is possible to use DOM events and observers to adjust the behavior of our built-in UI controls, but such low-level interventions are not recommended and may lead to unexpected behavior.
3) Is it possible to disable/hide specific fields in the Field List while keeping them active in rows/columns?
No, our component is designed to show all the fields in the Field List.
4) What would be the recommended approach to implement this requirement?
For the described use case, we recommend creating your own Field List control and using our events and API calls to apply all the changes to Flexmonster.
Here is the JSFiddle to illustrate the idea: https://jsfiddle.net/flexmonster/76r9cv0L/.
You can find the detailed instructions on creating a custom Field List control in the following guide: https://www.flexmonster.com/doc/creating-a-custom-ui-control-or-view/#creating-custom-field-list.
For your use case, we also suggest switching off dragging on the grid and updating the context menu, so users won't be able to remove the field by bypassing the Field List. Here is the example of how to remove the "Remove field" tab from the context menu: https://jsfiddle.net/flexmonster/gbuvksq3/.
Hope you will find our answer helpful. Don't hesitate to contact us if you need our further assistance with implementing a custom Field List control.
Kind regards,
Solomiia
Hello, Taehong!
Hope you are doing well.
Our team is wondering if you had some time to check our previous response about making some measures required in the Field List. Could you please let us know if the suggested approach of creating your own Field List control works well for you?
Looking forward to hearing from you.
Kind regards,
Solomiia