Hi lorenza,
Thanks for using Syncfusion Products.
The requested requirement can be achieved by using the client side event
RowSelected. Please find a sample and code example as below:
Sample:
MvcApplication17
<input type="text" id="txtbox"/>
@(Html.EJ().Grid<MvcApplication17.OrdersView>("FlatGrid")
.Datasource((IEnumerable<object>)ViewBag.datasource)
.AllowScrolling()
.AllowPaging() /*Paging Enabled*/
.Columns(col =>
{
col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add();
col.Field("CustomerID").HeaderText("Customer ID").Width(80).Add();
col.Field("EmployeeID").HeaderText("Employee ID").TextAlign(TextAlign.Right).Width(75).Add();
col.Field("Freight").HeaderText("Freight").TextAlign(TextAlign.Right).Width(75).Format("{0:C}").Add();
col.Field("OrderDate").HeaderText("Order Date").TextAlign(TextAlign.Right).Width(80).Format("{0:MM/dd/yyyy}").Add();
col.Field("ShipCity").HeaderText("Ship City").Width(110).Add();
})
.ClientSideEvents(eve=> eve.RowSelected("rowselected"))
)
|
The
RowSelected event will be triggered after a row has been selected and we can get the selected records values by using the method
getSelectedRecords.
<script>
function rowselected(args) {
var index= this.selectedRowsIndexes; //you can get the selected row index values
var selectedval = this.getSelectedRecords()[0].OrderID; //get the selected records values
$("#txtbox").val(selectedval);
}
</script>
|
We have displayed the selected records OrderID value to the input text box. Please refer the documentation for more details about
rowSelected event and
getSelectedRecords method in the following links
RowSelected Event:
http://help.syncfusion.com/UG/JS_CR/ejGrid.html#event:rowSelected
getSelectedRecord Method:
http://help.syncfusion.com/UG/JS_CR/ejGrid.html#getSelectedRecords
Please let us know if you have any queries.
Regards,
Balaji Marimuthu