Hi All,
I need to create an image column in my detail view. But the data field #= BroadcastEvent # is not recognized in client template at this line.
columns.Bound(o => o.BroadcastEvent).Title("").ClientTemplate( "<img src='" + Url.Content("~/Images/") + "#= BroadcastEvent #.png' />" );
#=DataField is always taking the Master Grid Data source. How can we access Data field of Detail view in client template on Detail view?
Code for Master grid
@(Html.Kendo().Grid<iPort.Models.CalanderItems>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(e => e.Time);
columns.Bound(e => e.CalanderStartTime).Hidden();
})
.Sortable()
.Pageable()
.ClientDetailTemplateId("template")
.DataSource(dataSource => dataSource
.Ajax()
.Model(model => model.Id(p => p.ID))
.Read(read => read.Action("GetCalanderData", "ClientViewActLogGrid"))
)
.Events(events => events.DataBound("dataBound"))
)
The data source for master grid is iPort.Models.CalanderItems
public class CalanderItems
{
public long ID {get; set;}
public DateTime CalanderStartTime { get; set; }
public string Time { get; set; }
public DateTime CalanderEndTime { get; set; }
}
Code for Detail Grid
<script id="template" type="text/kendo-tmpl">
@(Html.Kendo().Grid<iPort.Models.CalanderActivity>()
.Name("grid_#=ID#")
.Columns(columns =>
{
columns.Bound(o => o.BroadcastEvent).Title("").ClientTemplate( "<img src='" + Url.Content("~/Images/") + "#= BroadcastEvent #.png' />" );
columns.Bound(o => o.OccurranceTime);
columns.Bound(o => o.Title);
columns.Bound(o => o.Place);
columns.Bound(o => o.Description);
})
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("GetCalanderActivities", "ClientViewActLogGrid", new { StartTime = "#=ID#" }))
)
.Pageable()
.Sortable()
.ToClientTemplate()
)
</script>
The datasource for detail grid is
iPort.Models.CalanderActivity
public class CalanderActivity
{
public long ID {get; set;}
public string Title {get; set;}
public DateTime OccurranceDate {get; set;}
public string OccurranceTime { get; set; }
public string Description { get; set; }
public string Place { get; set; }
public string BroadcastEvent { get; set; }
}
I need to create an image column in my detail view. But the data field #= BroadcastEvent # is not recognized in client template at this line.
columns.Bound(o => o.BroadcastEvent).Title("").ClientTemplate( "<img src='" + Url.Content("~/Images/") + "#= BroadcastEvent #.png' />" );
#=DataField is always taking the Master Grid Data source. How can we access Data field of Detail view in client template on Detail view?
Code for Master grid
@(Html.Kendo().Grid<iPort.Models.CalanderItems>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(e => e.Time);
columns.Bound(e => e.CalanderStartTime).Hidden();
})
.Sortable()
.Pageable()
.ClientDetailTemplateId("template")
.DataSource(dataSource => dataSource
.Ajax()
.Model(model => model.Id(p => p.ID))
.Read(read => read.Action("GetCalanderData", "ClientViewActLogGrid"))
)
.Events(events => events.DataBound("dataBound"))
)
The data source for master grid is iPort.Models.CalanderItems
public class CalanderItems
{
public long ID {get; set;}
public DateTime CalanderStartTime { get; set; }
public string Time { get; set; }
public DateTime CalanderEndTime { get; set; }
}
Code for Detail Grid
<script id="template" type="text/kendo-tmpl">
@(Html.Kendo().Grid<iPort.Models.CalanderActivity>()
.Name("grid_#=ID#")
.Columns(columns =>
{
columns.Bound(o => o.BroadcastEvent).Title("").ClientTemplate( "<img src='" + Url.Content("~/Images/") + "#= BroadcastEvent #.png' />" );
columns.Bound(o => o.OccurranceTime);
columns.Bound(o => o.Title);
columns.Bound(o => o.Place);
columns.Bound(o => o.Description);
})
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("GetCalanderActivities", "ClientViewActLogGrid", new { StartTime = "#=ID#" }))
)
.Pageable()
.Sortable()
.ToClientTemplate()
)
</script>
The datasource for detail grid is
iPort.Models.CalanderActivity
public class CalanderActivity
{
public long ID {get; set;}
public string Title {get; set;}
public DateTime OccurranceDate {get; set;}
public string OccurranceTime { get; set; }
public string Description { get; set; }
public string Place { get; set; }
public string BroadcastEvent { get; set; }
}