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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How do I attach a Client side event on selection of a row on Grid?

Thread ID:

Created:

Updated:

Platform:

Replies:

127935 Dec 20,2016 11:34 AM UTC Dec 21,2016 09:13 AM UTC ASP.NET Core 2
loading
Tags: Grid
Samved Thakkar
Asked On December 20, 2016 11:34 AM UTC

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.


Thanks

Samved Thakkar
Replied On 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? 

Mani Sankar Durai [Syncfusion]
Replied On 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. 
[Index.cshtml] 
 
<button id="btn" onclick="myFunction()">get selected row value</button> 
<ej-grid id="Grid" datasource=ViewBag.data allow-paging="true" row-selected="rowselected" > 
    <e-columns> 
                      ... 
    </e-columns> 
     
</ej-grid> 
<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  
 
    } 
</script> 

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. 

Regards, 
Manisankar Durai. 


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.

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

;