I have a data grid and I would like to know how to access the columns and their values from the grid events. In this case, the rowSelected event.
I debugged the function and it returns row 0 for the selected row index which is correct since there was only one result. However, I now need to access the other fields like ReportNumber, CustomerName, etc.
What is the proper syntax to parse the selectedrecords object returned from the getSelectedRecords() method?
<ejs-grid id="reportGrid" dataSource="@Model.CreditReports" allowPaging="false" allowSelection="true" rowSelected="rowSelected" row>
<e-grid-selectionsettings enableSimpleMultiRowSelection="true" type="Multiple"></e-grid-selectionsettings>
<e-grid-columns>
<e-grid-column field="Id" visible="false" isPrimaryKey="true"></e-grid-column>
<e-grid-column field="ReportNumber" headerText="Report #" textAlign="Left"></e-grid-column>
<e-grid-column field="CustomerName" headerText="Customer" textAlign="Left"></e-grid-column>
<e-grid-column field="JointCustomerName" headerText="Joint Customer" textAlign="Left"></e-grid-column>
<e-grid-column field="Imported" headerText="Imported" headerTextAlign="Center" displayAsCheckBox="true" textAlign="Center"></e-grid-column>
<e-grid-column field="ImportedDate" headerText="Imported Date" format="dd/MM/yyyy"></e-grid-column>
</e-grid-columns>
</ejs-grid>
'
function rowSelected(args) {
var selectedrowindex = this.getSelectedRowIndexes(); // get the selected row indexes.
alert(selectedrowindex); // to alert the selected row indexes.
alert("Row " + selectedrowindex + " was selected."); // to alert the selected row indexes.
var selectedrecords = this.getSelectedRecords(); // get the selected records.
}