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
close icon

¿How server side and client side access to selected rows?

On v14.1.0.46 , How could I server side (C#) and client side access to selected rows in the Grid?

2 Replies

DC Daniel Cruzado Jimenez June 6, 2016 04:05 PM UTC

I means not Row Index. I means the Row object.


PK Prasanna Kumar Viswanathan Syncfusion Team June 7, 2016 12:36 PM UTC

Hi Daniel, 

Thank you for using Syncfusion products. 

To get the values from the selected row in client-side, use recordClick event of the ejGrid. This event is triggered when the record is clicked. In this event, we can get the selected row data in the arguments.       
 
Find the code example and sample: 


// Client-Side 

<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent"> 
        <ej:Grid ID="Grid" runat="server" AllowPaging="True" AllowSorting="true" OnServerRecordClick="Grid_ServerRecordClick"> 
           <EditSettings AllowEditing="True" AllowAdding="True" AllowDeleting="True"></EditSettings> 
           <ToolbarSettings ShowToolbar="True" ToolbarItems="add,edit,delete,update,cancel"></ToolbarSettings> 
            <ClientSideEvents RecordClick="recordclick" />  
            <Columns> 
--------------------------------------------------- 
            </Columns> 
        </ej:Grid> 
 
<script> 
    function recordclick(args) { 
        var rowdata = args.data; 
    } 
</script> 
</asp:Content> 



Help document to know more about recordClick event:   


You can also get all the selected row values using the getSelectedRecords method. For more information, refer to the below help document: 


To get selected rows data on server side, use server side event “OnServerRecordClick”. In recordclick event, you can get the selected row in the data property of GridEventArgs arguments  

Find the code example: 


<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent"> 
        <ej:Grid ID="Grid" runat="server" AllowPaging="True" AllowSorting="true" OnServerRecordClick="Grid_ServerRecordClick"> 
           <EditSettings AllowEditing="True" AllowAdding="True" AllowDeleting="True"></EditSettings> 
           <ToolbarSettings ShowToolbar="True" ToolbarItems="add,edit,delete,update,cancel"></ToolbarSettings> 
            <ClientSideEvents RecordClick="recordclick" /> 
            <Columns> 
                --------------------------------------- 
           </Columns> 
        </ej:Grid> 
</asp:Content> 
 
--------------------------------------------------- 
protected void Grid_ServerRecordClick(object sender, GridEventArgs e) 
        { 
            Orders value = new Orders(); 
            List<Orders> data = ViewState["DataSource"] as List<Orders>; 
            Dictionary<string, object> KeyVal = e.Arguments["data"] as Dictionary<string, object>; 
          
                foreach (KeyValuePair<string, object> keyval in KeyVal) 
                { 
                   if (keyval.Key == "OrderID")                
                        value.OrderID = Convert.ToInt32(keyval.Value); 
                    else if (keyval.Key == "CustomerID") 
                        value.CustomerID = Convert.ToString(keyval.Value); 
                    else if (keyval.Key == "EmployeeID") 
                        value.EmployeeID = Convert.ToInt32(keyval.Value); 
                    else if (keyval.Key == "Freight") 
                        value.Freight = Convert.ToDouble(keyval.Value); 
                    else if (keyval.Key == "ShipCity") 
                        value.ShipCity = Convert.ToString(keyval.Value); 
                   } 
               } 
 
        } 

Regards, 
Prasanna Kumar N.S.V 


Loader.
Live Chat Icon For mobile
Up arrow icon