We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback
Essential JS2

Syncfusion jQuery based widgets are no longer in active development. Switch to our pure JavaScript based next generation Essential JS 2 library.

Is there any way to put Edit Delete and Add buttons to the same cell in ejTreeGrid?

Thread ID:

Created:

Updated:

Platform:

Replies:

146608 Aug 10,2019 01:48 AM UTC Aug 21,2019 06:12 AM UTC jQuery 3
loading
Tags: ejTreeGrid
xia
Asked On August 10, 2019 02:30 AM UTC

Hi

We had a demand to put Edit Delete and Add buttons to the same cell(parent row) in ejTreeGrid.

We noticed the demo site has an example about column command, but that can only put Edit Delete or Save Cancel into a cell at the same time.

Here is our prototype design -- https://drive.google.com/open?id=10x7PO0Hq5cHy48SDkqAbkCCXHOwsay29

Could someone help us? Thank you

Pooja Priya Krishna Moorthy [Syncfusion]
Replied On August 12, 2019 09:44 AM UTC

Hi Xia, 
 
We can include custom buttons in command column to perform custom actions using the type property. By using queryCellInfo event of TreeGrid control, we can include the custom buttons only for the parent records. By using the addRow method, we can dynamically add the empty rows on custom button click action, using the click event of button control. 
Please find the below code example. 
 
 
<script> 
       $("#TreeGridContainer").ejTreeGrid({ 
              //... 
              columns: [ 
              //... 
                      { 
                      field: 'custom', headerText: "Command Column", 
                      commands: [ 
                                    //... 
                                    { type: "Add", buttonOptions: { text: "Add", click: addRow } }, 
                             ] 
                      } 
              ], 
              queryCellInfo: function(args){ 
                      if (args.column.field == "custom") { 
                         if(!args.data.hasChildRecords){ 
                             $(args.cellElement).find(".e-Addbutton").css({ 'display': 'none'}); 
                         } 
                      } 
              } 
       }) 
       function addRow(args){ 
              var obj =  $("#TreeGridContainer").ejTreeGrid("instance"); 
              var index = obj.getIndexByRow(args.target.closest("tr")); 
              obj.selectRows(obj.getUpdatedRecords().indexOf(obj.model.currentViewData[index])); 
              var data = {}; 
              obj.addRow(data, ej.TreeGrid.RowPosition.Child); 
       } 
}); 
</script> 
 
Please find the below sample link. 
 
Regards, 
Pooja Priya K. 


xia
Replied On August 21, 2019 01:28 AM UTC

Hi Xia, 
 
We can include custom buttons in command column to perform custom actions using the type property. By using queryCellInfo event of TreeGrid control, we can include the custom buttons only for the parent records. By using the addRow method, we can dynamically add the empty rows on custom button click action, using the click event of button control. 
Please find the below code example. 
 
 
<script> 
       $("#TreeGridContainer").ejTreeGrid({ 
              //... 
              columns: [ 
              //... 
                      { 
                      field: 'custom', headerText: "Command Column", 
                      commands: [ 
                                    //... 
                                    { type: "Add", buttonOptions: { text: "Add", click: addRow } }, 
                             ] 
                      } 
              ], 
              queryCellInfo: function(args){ 
                      if (args.column.field == "custom") { 
                         if(!args.data.hasChildRecords){ 
                             $(args.cellElement).find(".e-Addbutton").css({ 'display': 'none'}); 
                         } 
                      } 
              } 
       }) 
       function addRow(args){ 
              var obj =  $("#TreeGridContainer").ejTreeGrid("instance"); 
              var index = obj.getIndexByRow(args.target.closest("tr")); 
              obj.selectRows(obj.getUpdatedRecords().indexOf(obj.model.currentViewData[index])); 
              var data = {}; 
              obj.addRow(data, ej.TreeGrid.RowPosition.Child); 
       } 
}); 
</script> 
 
Please find the below sample link. 
 
Regards, 
Pooja Priya K. 


Thank you Pooja Priya K!

Gurunathan A [Syncfusion]
Replied On August 21, 2019 06:12 AM UTC

Hi Xia, 
  
You are welcome. 
  
Regards, 
Gurunathan 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon