<ej:grid ID="gvAlumnos" runat='server' AllowPaging="True"> <ClientSideEvents RowSelected ="rowSelect" /> <Columns> <ej:Column Field="CustomerID" HeaderText="CustomerID" Width="75" /> <ej:Column Field="OrderID" HeaderText="OrderID" /> </Columns> </ej:grid> function rowSelect() { var obj = $("#MainContent_gvAlumnos").ejGrid("instance"); //getSelectedRecords method will display the selected row in a grid alert(obj.getSelectedRecords()[0].CustomerID); } |
[Default.aspx] <ej:grid ID="gvAlumnos" runat='server' AllowPaging="True" AllowGrouping="true" OnServerRowSelected="gvAlumnos_ServerRowSelected"> <Columns> <ej:Column Field="CustomerID" HeaderText="CustomerID" Width="75" /> <ej:Column Field="OrderID" HeaderText="OrderID" /> <ej:Column Field="EmployeeID" HeaderText="EmployeeID" Width="75" /> <ej:Column Field="ShipCity" HeaderText="ShipCity" Width="75" /> </Columns> </ej:grid> [Default.aspx.vb] Protected Sub gvAlumnos_ServerRowSelected(sender As Object, e As Syncfusion.JavaScript.Web.GridEventArgs) Dim selectedrowindex As Integer = Convert.ToInt32(e.Arguments("rowIndex")) Dim id As Integer Dim data As Dictionary(Of String, Object) = TryCast(e.Arguments("data"), Dictionary(Of String, Object)) For Each keyval As KeyValuePair(Of String, Object) In data If keyval.Key = "EmployeeID" Then //find the EmployeeID column value. id = keyval.Value End If Next End Sub |
$("#Grid").ejGrid({ dataSource: data, allowPaging: true, allowSorting: true, columns: [ { field: "OrderID", headerText: "Order ID", width: 75, textAlign: ej.TextAlign.Right }, { field: "CustomerID", headerText: "Customer ID", width: 80 }, ], //client side event rowSelected: "rowSelected", }); function rowSelected() { var obj = $("#Grid").ejGrid("instance"); //getSelectedRecords method will display the selected row in a grid alert(obj.getSelectedRecords()[0].CustomerID); } |
[code behind]
Public Class _Default
Inherits System.Web.UI.Page
Dim Shared selectedData 'global variable declaration
Protected Sub Submit(sender As Object, e As EventArgs)
Dim selectedRows As Object
selectedRows = selectedData 'global variable resue
End Sub
Protected Sub gvAlumnos_ServerRowSelected(sender As Object, e As Syncfusion.JavaScript.Web.GridEventArgs)
Dim selectedrowindex As Integer = Convert.ToInt32(e.Arguments("rowIndex"))
Dim id As Integer
Dim data As Dictionary(Of String, Object) = TryCast(e.Arguments("data"), Dictionary(Of String, Object))
For Each keyval As KeyValuePair(Of String, Object) In data
If keyval.Key = "EmployeeID" Then
id = keyval.Value
End If
Next
selectedData = data
End Sub
End Class
[aspx]
<asp:Button ID="selectRow" runat="server" OnClick=" Submit" Text="getSelectedRecords" />
<ej:grid ID="gvAlumnos" runat='server' AllowPaging="True"
. . .
</ej:grid> |
DLLs |
Syncfusion.EJ.dll
Syncfusion.EJ.Web.dll |
Script files |
Syncfusion script files:
ej.web.all.min.js
ej.unobtrusive.min.js
External Script files:
jquery.min.js
jquery.easing.min.js
jsrender.min.js
jquery.validate.min.js |
CSS files |
ej.widgets.core.min.css |
[web.config]
<compilation debug="true" targetFramework="4.5" >
<assemblies>
<add assembly="Syncfusion.EJ, Version= 14.2400.0.26, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89" />
<add assembly="Syncfusion.EJ.Web, Version= 14.2400.0.26, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89" />
</assemblies>
</compilation> |