<ejs-grid id="Grid" dataSource="@ViewBag.gridData" allowPaging="true" queryCellInfo="template">
<e-grid-columns>
<e-grid-column field="OrderID" headerText="Order ID" textAlign="Right" width="120"></e-grid-column>
<e-grid-column field="CustomerID" headerText="Customer Name" width="150"></e-grid-column>
<e-grid-column field="OrderDate" headerText=" Order Date" textAlign="Right" format="yMd" width="130"></e-grid-column>
<e-grid-column field="Freight" headerText="Freight" textAlign="Right" format="C2" width="120"></e-grid-column>
<e-grid-column field="ShippedDate" headerText="Shipped Date" textAlign="Right" format="yMd" width="140"></e-grid-column>
<e-grid-column field="ShipCountry" headerText="Ship Country" width="150"></e-grid-column>
<e-grid-column field="EmployeeID" headerText="Rating column" textAlign="Left" width="120" template="#columnTemplate"></e-grid-column>
</e-grid-columns>
</ejs-grid>
<script type="text/x-jsrender" id="columnTemplate">
<input type="text" id="${EmployeeID}" class="rating" /> //Using this EmployeeID field you can set the unique id
</script>
<script type="text/javascript">
function template(args) {
if (args.column.field == "EmployeeID") {
$(args.cell).find(".rating").ejRating({ //Rendering EJ Rating control
value: 2
});
}
}
</script> |
<script type="text/javascript">
function template(args) {
if (args.column.field == "EmployeeID") {
$(args.cell).find(".rating").ejRating({
value: 2,
change: function (val) {
var getID = this.element[0].id; //retrieve the element id
}
});
}
}
</script> |