[html]
<div id="template1">
Order ID
<div class="e-updown" style="float:right;width:16px;height:30px">
<span><img src="../content/ejthemes/common-images/reports/updown.png"></span>
</div>
</div>
<div id="template2">
Customer ID
<div class="e-updown" style="float:right;width:16px;height:30px">
<span><img src="../content/ejthemes/common-images/reports/updown.png"></span>
</div>
</div>
<div id="template3">
Employee ID
<div class="e-updown" style="float:right;width:16px;height:30px">
<span><img src="../content/ejthemes/common-images/reports/updown.png"></span>
</div>
</div>
<ej-grid id="FlatGrid" datasource="ViewBag.datasource" allow-sorting="true" action-complete="ActionComplete">
<e-columns>
<e-column field="OrderID" header-text="Order ID" width="90" header-template="#template1"></e-column>
<e-column field="CustomerID" header-text="Customer ID" width="100" header-template="#template2"></e-column>
<e-column field="EmployeeID" header-text="Employee ID" width="100" header-template="#template3"></e-column>
</e-columns>
</ej-grid>
[JS]
<script type="text/javascript">
function ActionComplete(args) {
if (args.requestType == "sorting") {
//To hide and show icon based on the sort direction
var colIndex = this.getColumnIndexByField(args.columnName);
var $th = this.getHeaderTable().find("th");
$th.eq(colIndex).find("span.e-icon").hide();
$th.find("img").attr("src", "../content/ejthemes/common-images/reports/updown.png");
if (args.columnSortDirection == "ascending")
$th.eq(colIndex).find("img").attr("src", "../content/ejthemes/common-images/reports/up.png");
else
$th.eq(colIndex).find("img").attr("src", "../content/ejthemes/common-images/reports/down.png");
}
}
</script> |