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 do I attach a Client side event on selection of a row on Grid?

I want to be able to call a Client side event i.e. a java script function when you select a row on Grid and in get the values for the selected row.

How do I do this? I couldn't find an example on your website.


2 Replies

ST Samved Thakkar December 20, 2016 11:42 AM UTC

Also, how do I get the values of the selected row of a grid on a separate button's client side event? 

MS Mani Sankar Durai Syncfusion Team December 21, 2016 09:13 AM UTC

Hi Samved, 

Thank for contacting Syncfusion support. 

We have analyzed your query and we can get the selected records value using getSelectedRecords method or rowSelected events in grid. Please refer the documentation link. 

Please refer the below code example. 
<button id="btn" onclick="myFunction()">get selected row value</button> 
<ej-grid id="Grid" datasource=ViewBag.data allow-paging="true" row-selected="rowselected" > 
<script type="text/javascript"> 
    function rowselected(args) { 
        var grid = $("#Grid").ejGrid("instance"); 
        var rowdata = args.data;   // get the selected value using args.data in rowSelected event 
        var rowindex = args.rowIndex; 
        var rowdata1 = this.getSelectedRecords();  //also we can get it by using getSelectedRecords method in grid and ‘this’ keyword refers to grid instance. 
    function myFunction() { 
                     //getting the value by using external button 
        var grid = $("#Grid").ejGrid("instance");     // create a grid instance 
        if (grid.getSelectedRows().length) 
        alert(JSON.stringify(grid.getSelectedRecords()[0]));   //we can get it by using getSelectedRecords method in grid  

We have also prepared a sample that can be downloaded from the below link. 

Also please refer the following KB link: 

Please let us know if you need further assistance. 

Manisankar Durai. 

Live Chat Icon For mobile
Up arrow icon