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. Image for the cookie policy date

How to get values of selected grid row if one customized buttons is clicked on toolbar?

Hi,

I customize one item on toolbar and define toolbarClick (:toolbarClick="toolbarClickHandler"). But I find args (given in toolbarClickHandler: function(args)) don't include those values of selected grid row, how can I get them?

Thanks,
Jzy

3 Replies

PS Pavithra Subramaniyam Syncfusion Team March 5, 2019 11:25 AM UTC

Hi Jzy, 
 
Thanks for contacting Syncfusion support. 
 
In Essential JavaScript 2 Grid, ‘toolbarClickEventArgs’ will contains only the default arguments from the source. We suspect that you want to get the selected row information inside the toolbarClick event of Grid. If yes you can achieve your requirement by using the ‘getSelectedRows()’ and ‘getSelectedRecords()’ methods of Grid component. Please refer to the below code example, documentation link and sample link for more information. 
 
[vue] 
 new Vue({   
              el: '#app', 
              template: ` 
    <div id="app"> 
        <ejs-grid id="Grid" ref="grid" :dataSource="data" :selectionSettings="selection" :toolbar='toolbar' :toolbarClick='clickHandler' height='315px'> 
          <e-columns> 
            <e-column field='OrderID' headerText='Order ID' isPrimaryKey='true' textAlign='Right' width=90></e-column> 
            .   .  . 
          </e-columns> 
        </ejs-grid> 
    </div> 
`, 
 
  data() { 
    return { 
      data: data.slice(0,20), 
      selection:{type:'Multiple'}, 
      toolbar: [{ text: 'Row Info', tooltipText: 'Row Info',  id: 'rowinfo' }],        
    }; 
  }, 
   methods: { 
      clickHandler: function(args) { 
        if (args.item.id === 'rowinfo') { 
            console.log(this.$refs.grid.ej2Instances.getSelectedRows()); 
            console.log(this.$refs.grid.ej2Instances.getSelectedRecords()); 
        }         
    }      
   }, 
    provide: { 
    grid: [Toolbar,Page] 
  } 
}); 
 
                              https://ej2.syncfusion.com/vue/documentation/api/grid/#getselectedrecords  
                              https://ej2.syncfusion.com/vue/documentation/api/grid/#getselectedrows  
 
Sample               : https://plnkr.co/edit/TN2LoskjgIzMsWVgvxDN?p=preview  
 
Please get back to us if you need any further assistance on this. 
 
Regards, 
Pavithra S. 
 



WM William Morgenweck August 31, 2019 08:28 PM UTC

This documentation really does not say anything.  No understanding of how to use it.  Will this be improved?


DR Dhivya Rajendran Syncfusion Team September 2, 2019 07:42 AM UTC

Hi William, 

Thanks for your update. 

We have already documented how to use custom toolbar and toolbar items in Grid. Please refer the below help documentation for more information. 


As per your suggestion, we will improve our documentation and will add “How to get selected records in custom toolbar click” in toolbar section, which will refresh in any of our upcoming release. 
   
Regards, 
R.Dhivya 


Loader.
Live Chat Icon For mobile
Up arrow icon