How to include a custom button in dialog editor for JS TreeGrid?
In JavaScript Tree grid, while using custom template for edit dialog, the inbuilt save and cancel buttons will be displayed for performing the necessary actions. But it is possible to remove these default dialog buttons and a custom button can be included in the dialog.
The below code snippet explains how to remove the default dialog buttons and to include a custom button for delete action.
<script type="text/x-jsrender" id="Template"> <input type="button" value="DeleteRecord" id="deleteItem" onclick="deleteRecord()"/> </script> <script type="text/javascript"> $(function () { dataSource: sampleData, childMapping: "subtasks", editSettings: { allowAdding: true, allowEditing: true, allowDeleting: true, editMode: "dialogEditing", dialogEditorTemplateID: "#Template" }, actionBegin: function (args) { //Codes for removing the save cancel buttons from Edit Dialog if (args.requestType == "openEditDialog") { $(".e-editform-btn").find(".e-save").remove(); $(".e-editform-btn").find(".e-cancel").remove(); } if (args.requestType == "openAddDialog") { $("#deleteItem").remove(); } }, //.. }) }); function deleteRecord() { var treeObj = $("#TreeGridContainer").data("ejTreeGrid"); selectedItem = treeObj.model.selectedItem; treeObj.deleteRow(); $("#TreeGridContainer_dialogEdit").ejDialog("close"); } </script>
You can also find a sample to include a custom button in edit dialog here.
Conclusion
I hope you enjoyed learning about how to include a custom button in dialog editor.
You can refer to our JavaScript TreeGrid 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 JavaScript TreeGrid 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!