How to hide the check boxes and context menu in PivotGrid?
This KB illustrates that how to hide the check boxes and context menu in Field List.
Solution
In-general, PivotSchemaDesigner has many UI options to add/remove/move fields in desired field area. The options are,
- Drag and drop from Field List to field area
- Check boxes
- Context menu
Below screen-shot shows the check boxes and context menu in PivotSchemaDesigner.
You can hide the check boxes and context menu under Field List of PivotSchemaDesigner by using below steps.
To hide check boxes, we can utilize their class name “.schemaFieldList .e-chkbox-small” and apply the CSS style “display: none”, which hides the entire check boxes under Field List.
To hide context menu, the required code is written inside the “OnAfterServiceInvoke” event of PivotSchemaDesigner. Like check boxes, we can utilize the class name of the context menu to remove it using jQuery. The code is like $(".pivotTreeContext").remove() under the function “hideContextMenu()” as mentioned in the below code sample.
NOTE: The class “.pivotTreeContext” of the context menu will be generated only after PivotGrid control is rendered. Calling the function “hideContextMenu()” before that could not be effective. So we have to set delay, in-order to activate the function “hideContextMenu()” using “setTimeout” function.
The code sample below illustrates on how to hide the check boxes in Field List.
CSS
<style> .schemaFieldList .e-chkbox-small { display: none; } </style>
The code sample below illustrates on how to hide the context menu in Field List.
Script
@Html.EJ().Pivot().PivotGrid("PivotGrid1").Url(Url.Content("~/wcf/RelationalService.svc")).ClientSideEvents(events => events.AfterServiceInvoke("OnAfterServiceInvoke")) @Html.EJ().Pivot().PivotSchemaDesigner("PivotSchemaDesigner") <script type="text/javascript"> OnAfterServiceInvoke = function (evt) { if (evt.action == "initialize") { var PivotSchemaDesigner = $("#PivotSchemaDesigner").data('ejPivotSchemaDesigner'); if (PivotSchemaDesigner.model.pivotControl == null) { PivotSchemaDesigner.model.enableWrapper = true; PivotSchemaDesigner.model.pivotControl = this; PivotSchemaDesigner.model.layout = "excel"; PivotSchemaDesigner._load(); setTimeout(hideContextMenu, 500); } } } function hideContextMenu() { $(".pivotTreeContext").remove(); }</script>
Conclusion
I hope you enjoyed learning how to hide the check boxes and context menu in PivotGrid.
You can refer to our ASP.NET MVC PivotGrid feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our ASP.NET MVC PivotGrid example to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!