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

Control Gird


I have two points:

1. I want to get a row values by row index in Grid. 
2. In toolBox in grid I want  connect add and edit button with my custom function in server side. can I do that?


5 Replies

AS Alan Sangeeth S Syncfusion Team April 3, 2017 07:06 AM UTC

Hi Emanuele, 

Thanks for using Syncfusion products. 

Query 1: “get a row values by row index in Grid 
You can get the row element using getRowbyIndex method of Grid. Please refer the following API documentation link. 
If you need to get the JSON data, you get it by using “getDataByIndex” method of Grid. Please refer the following link. 

Query 2: “ connect add and edit button with my custom function in server side 
We suspect that you need to connect CRUD operation in Grid with server-side and you can achieve it using OnServerAddRow, OnServerEditRow, OnServerDeleteRow Grid events. Please refer to the following documentation for details regarding server-side interaction during CRUD operations. 

Suppose if you need to add customized buttons in grid toolbar, please refer the following documentations. 

Alan Sangeeth S 

EM emanuele April 3, 2017 07:29 AM UTC

Sorry, I didn't explain very well, for the first problem: I want get select row data in ServerToolBarClick events, and don't from JS.

For the second point, ok I understand that there isn't event before add.


AS Alan Sangeeth S Syncfusion Team April 4, 2017 10:14 AM UTC

Hi Emanuele, 
Using the SelectedRowIndex and PageSettings property of Grid, we can get the selected row data from Grid DataSource property in server side. Please refer the following code example. 
protected void Toolbar_Click(object sender, Syncfusion.JavaScript.Web.ButtonEventArgs e) 
            var selectedRowIndex = this.Grid1.Model.SelectedRowIndex; // here you will get SelectedRow index 
            int dataIndex; 
            if (this.Grid1.PageSettings.CurrentPage > 1) 
                dataIndex = (this.Grid1.Model.PageSettings.PageSize * (this.Grid1.Model.PageSettings.CurrentPage - 1)) + (selectedRowIndex); 
                dataIndex = selectedRowIndex; 
            var DataSource = this.Grid1.Model.DataSource; 
            JavaScriptSerializer mySerialiser = new JavaScriptSerializer(); 
            string sJSONOutput = mySerialiser.Serialize(DataSource); 
            var data = mySerialiser.Deserialize<IEnumerable<Orders>>(sJSONOutput); // here you will get all the records 
            var SelectedRow = data.ElementAt(dataIndex); // here you will get SelectedRow 
            var keyValue = SelectedRow.OrderID;  // here you will get selected RowKey value 

Alan Sangeeth S 

EM emanuele April 4, 2017 09:12 PM UTC

Hi, But how you see in screenshot the datasource  is null in grid. I don't understand why?I use datasourceobject and maybe it is the problemAttachment: ScreenShot_20170404230745_47055fb2.zip

VA Venkatesh Ayothi Raman Syncfusion Team April 5, 2017 12:34 PM UTC

Hi Emanuele, 
Thanks for the update. 
We have reproduced this issue while using object data source and using Essential Studio older version. In our latest version, the reported issue is not reproduced at our end. So, could you please ensure whether you are using older Essential Studio version? If so, we suggest you to upgrade the latest Essential Studio version. 
We have also prepared a sample for your convenience which can be download from following link, 
Note: in this sample, we have used the latest Essential Studio CDN links. 
Venkatesh Ayothiraman. 

Live Chat Icon For mobile
Up arrow icon