Hi,
I'm binding my grid to a DataTable for displaying dynamic search results. I've followed the example on how to do binding with DataTable, but I was wondering if there is a way to reference a different column in the Template / ClientTemplate. I've tried what I regularly do when bound to a Model/ViewModel, but it doesn't seem to work for DataTables. I've tried both
This is what my grid looks like:
Model.Result.Data is of type DataTable. It renders all the columns fine, but I'd like the name column to be a hyperlink to the details page.. Any suggestions?
Thank you
I'm binding my grid to a DataTable for displaying dynamic search results. I've followed the example on how to do binding with DataTable, but I was wondering if there is a way to reference a different column in the Template / ClientTemplate. I've tried what I regularly do when bound to a Model/ViewModel, but it doesn't seem to work for DataTables. I've tried both
This is what my grid looks like:
@(Html.Kendo().Grid(Model.Result.Data)
.Name("gridSearchResults")
.Columns(columns =>
{
foreach (System.Data.DataColumn column in Model.Result.Data.Columns)
{
if (column.ColumnName != "Id")
{
if (column.ColumnName == "Name")
{
columns.Bound("Name").Template(@<
text
><
a
href
=
'" + Url.Action("Details", Model.Result.DataSource) + "/#= Id #'
" + ">#= Name #</
a
></
text
>);
}
else
{
columns.Bound(column.ColumnName);
}
}
}
})
.DataSource(d => d
.Server()
.Model(m => {
m.Id("Id");
foreach (System.Data.DataColumn column in Model.Result.Data.Columns)
{
m.Field(column.ColumnName, column.DataType);
}
})
)
)
Model.Result.Data is of type DataTable. It renders all the columns fine, but I'd like the name column to be a hyperlink to the details page.. Any suggestions?
Thank you