Hi,
I would like to add hyperlinks in my grid rows. These hyperlinks must only display based on a certain condition. Is this possible? The hyperlinks should also have parameters attached to the for the specific row.
|
<div id="ControlRegion">
@Html.EJS().Grid("Grid").DataSource((IEnumerable<object>)ViewBag.dataSource).Columns(col =>
{
col.Field("EmployeeID").HeaderText("Employee ID").Width("120").Add();
col.Field("Country").Template("#template").Width("150").Add();
}).Render()
</div>
<script id="template" type="text/x-template">
<div>
${if(Country)}
${else}
<span>Not provided</span>
${/if}
</div>
</script> |
Thanks for the sample.
Can the condition be based on other cells in the grid?
As in your example provided, can the template in country column be based on a condition in the employee id column?
if employee id = 1 then rel='nofollow' href must contain employee id and country values as parameters
I have answered my own question. Yes, the condition can be based on other cells in the grid.
Thank you for your assistance
|
DataGridFeatures.cshtml
@{
ViewBag.Title = "DataGridFeatures";
}
<div id="ControlRegion">
@Html.EJS().Grid("Grid").DataSource((IEnumerable<object>)ViewBag.dataSource).Columns(col =>
{
col.Field("EmployeeID").HeaderText("Employee ID").Width("120").Add();
col.Field("FirstName").HeaderText("Name").Width("125").Add();
col.Field("Title").HeaderText("Title").Width("170").Add();
col.Field("Country").Template("#template").Width("150").Add();
col.Field("ReportsTo").HeaderText("ReportsTo").Width("120").Add();
}).Render()
</div>
<script id="template" type="text/x-template">
<div>
${if(EmployeeID != 1)}
${else}
${/if}
</div>
</script> |