or
@(Html.Kendo().Grid<LocationViewModel>()
.Name(
"locationGrid_#=CustomerID#"
)
.Columns(columns =>
{
columns.Bound(c => c.Name).Title(
"Location Name"
);
columns.Bound(c => c.Description).Title(
"Description"
);
columns.Bound(c => c.SummaryDescription).Title(
"Summary Description"
);
columns.Bound(c => c.Environment).Title(
"Environment Name"
);
//.ClientTemplate("\\#: Environment.Name \\#")
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(200);
})
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(10)
.Read(read => read.Action(
"GetLocations"
,
"Home"
,
new
{ customerID =
"#=CustomerID#"
}))
.Create(create => create.Action(
"AddLocation"
,
"Home"
,
new
{ id =
"#=CustomerID#"
}))
.Update(update => update.Action(
"UpdateLocation"
,
"Home"
))
.Destroy(update => update.Action(
"DeleteLocation"
,
"Home"
))
.Model(model =>
{
model.Id(m => m.LocationID);
})
.Events(e => e.Error(@<text>function(e) { onError(e,
"locationGrid_#=CustomerID#"
,
"locationErrors"
) }</text>))
)
.ToolBar(toolbar => toolbar.Create().Text(
"Add Location"
))
.Editable(editable => editable.Mode(GridEditMode.InLine))
.Pageable()
.Sortable()
.ToClientTemplate()
)
public
class
LocationViewModel
{
public
Guid? LocationID {
get
;
set
; }
[Required]
[StringLength(256)]
public
string
Name {
get
;
set
; }
[StringLength(1024)]
public
string
Description {
get
;
set
; }
public
int
TestPointNo {
get
;
set
; }
public
MarketViewModel Market {
get
;
set
; }
[UIHint(
"EnvironmentEditor"
)]
public
EnvironmentViewModel Environment {
get
;
set
; }
public
int
TimeZoneGmtOffset {
get
;
set
; }
public
double
Latitude {
get
;
set
; }
public
double
Longitude {
get
;
set
; }
public
double
HAE {
get
;
set
; }
public
bool
Deleted {
get
;
set
; }
[StringLength(512)]
public
string
SummaryDescription {
get
;
set
; }
}
@(Html.Kendo().DropDownList()
.Name(
"EnvironmentViewModel"
)
.DataValueField(
"EnvironmentID"
)
.DataTextField(
"Name"
)
.DataSource(d =>
{
d.Read(r => r.Action(
"GetEnvironmentsJsonResult"
,
"Home"
).Data(
"getCustomerID()"
)).ServerFiltering(
true
);
}
)
.SelectedIndex(0)
)
function
updateReconcileCB(cb) {
var
grid = $(
"#Receipts"
).data(
"kendoGrid"
);
var
di = grid.dataItem(grid.select());
di.selected = cb.checked;
}
@(Html.Kendo().Grid<
Reviews.Models.Review
>().Name("ReviewGrid").Columns(columns =>
{
columns.Bound(p => p.Customer);
columns.Bound(p => p.Location);
columns.Bound(p => p.Title).ClientTemplate("<
strong
>#: Title #</
strong
>"); //This works
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(200);
})
.ToolBar(toolbar => toolbar.Create().Text("Ný Skyrsla"))
.DetailTemplate(detail => detail.ClientTemplate(
Html.Kendo().Grid<
Reviews.Models.ReviewCategory
>()
.Name("ReviewCategory_#=ReviewID#")
.Columns(columns =>
{
columns.Bound(o => o.TableNo);
columns.Bound(o => o.Category);
columns.Bound(o => o.Comment);
//columns.Bound(o => o.PerformedDate);
// columns.Bound(o => o.Id).ClientTemplate("<
img
alt
=
'#: Id #'
src='"
//+ Url.Content("~/Report/ViewPic/")
// + "#: Id #' />").Title("Picture");
columns.Bound(o => o.TableNo).ClientTemplate("<
strong
>#: TableNo #</
strong
>");//tthis does not work
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(200);
})
.ToolBar(toolbar => toolbar.Create())
.Editable(editable => editable.Mode(GridEditMode.InLine))
.Pageable()
.Sortable()
.Scrollable()
.DataSource(dataSource => dataSource
.Ajax()
.Events(events => { events.Error("error_handler"); })
.Model(model => model.Id(p => p.Id))
.Create(update => update.Action("ReviewCategory_Create", "Home", new { reviewId = "#=ReviewID#" }))
.Read(read => read.Action("ReviewCategory_Read", "Home", new { id = "#=ReviewID#" }))
.Update(update => update.Action("ReviewCategory_Update", "Home", new { reviewId = "#=ReviewID#" }))
.Destroy(update => update.Action("ReviewCategory_Destroy", "Home"))
)
.ToHtmlString()
))
.Editable(editable => editable.Mode(GridEditMode.InLine))
.Pageable()
.Sortable()
.Scrollable()
.DataSource(dataSource => dataSource
.Ajax()
.Events(events => { events.Error("error_handler"); })
.Model(model => model.Id(p => p.ReviewID))
.Create(update => update.Action("Review_Create", "Home"))
.Read(read => read.Action("Review_Read", "Home"))
.Update(update => update.Action("Review_Update", "Home"))
.Destroy(update => update.Action("Review_Destroy", "Home"))
)
)
The first clientTemplate works and
#: Title # get bound to Review.Title.
The second clientTemplate does not work, a js error comes , it says can not bind to TableNo. Writing Title instead of Table No will however display the title from Review class. so eventhourgh my grid is bound to ReviewCategory class the clienttemplate is displaying value from Review class.
Is this a bug ?.
Best
Ole