@(Html.EJ().Grid<object>("ColumnTemplate")
.Datasource((IEnumerable<object>)ViewBag.datasource)
.AllowPaging()
.PageSettings(page => { page.PageSize(4); })
.ClientSideEvents(e=>e.TemplateRefresh("Trefresh"))
.Columns(col =>
{
col.HeaderText("Employee Image").Template("#columnTemplate").TextAlign(TextAlign.Center).Width(110).Add();
…………………………………………………
})
)
<script type="text/x-jsrender" id="columnTemplate">
<span> {{:FirstName}}</span>
</script>
<script type="text/javascript">
function Trefresh(args) {
if (args.column.headerText == "Employee Image") {
if ($(args.cell).text().includes(":")) {
var txt = $(args.cell).text().split(":")[0];
$(args.cell).text(txt);
}
}
}
</script>
//////////////////////////
private void BindDataSource()
{
order.Add(new Orders(1, "Nancy:", "Sales Representative", "Seattle", "USA"));
order.Add(new Orders(2, "Andrew", "Vice President, Sales", "Tacoma", "USA"));
order.Add(new Orders(3, "Janet", "Sales Representative", "Kirkland", "USA"));
order.Add(new Orders(4, "Margaret", "Sales Representative", "Redmond", "USA"));
order.Add(new Orders(5, "Steven", "Sales Manager", "London", "UK"));
order.Add(new Orders(6, "Michael", "Sales Representative", "London", "UK"));
order.Add(new Orders(7, "Robert", "Sales Representative", "London", "UK"));
order.Add(new Orders(8, "Laura", "Inside Sales Coordinator", "Seattle", "USA"));
order.Add(new Orders(9, "Anne", "Sales Representative", "London", "UK"));
}
|
|