|
<ej-column>
<ej-template>
<button id="${id}" ej-button="e-size.bind: miniBtnValue;
e-show-rounded-corner.bind: roundedCorner;
e-content-type: textandimage;
e-prefix-icon: e-icon e-uiLight e-edit;
e-text: Edit"
e-is-unbound="true"
e-on-click.delegate="editCustomer($event)"></button>
...
editCustomer(e){
var grid = $(".e-grid").ejGrid("instance");
var index = grid.getIndexByRow($(e.target).closest("tr")) //get the rowindex based on the target.
var id = grid.model.dataSource()[index].OrderID;
//get the value from the dataSource based on the index.
} |
That did not work for me due to the pagination.
If page one has 2 rows and page 2 has 1 row and I am on page 2 clicking on a button in the only row on that page, the code provided will get index 0.
That will result on the retrieval of the data from the first row in page one, not page 2.
|
editCustomer(e){
var grid = $(".e-grid").ejGrid("instance");
var index = grid.getIndexByRow($(e.target).closest("tr"))
var id = grid.model.currentViewData[index].OrderID;
alert(id);
} |