or
public
class
MainViewModel{
public
IList<SubViewModel> SubViewModels;
}
public
class
SubViewModel{
public
Guid Id;
public
string
Name;
public
IList<Guid> CategoryIds;
public
IList<CategoryType> CategoryTypes;
}
public
class
CategoryType {
public
Guid Id;
public
string
Type;
}
var
initialData = @Html.Raw(JsonConvert.SerializeObject(Model,
new
JavaScriptDateTimeConverter()));
var
mainViewModel =
new
MainViewModel(initialData);
function
MainViewModel(data) {
var
mapping = {
'SubViewModels'
:
create:
function
(options) {
return
new
SubViewModel(options.data);
}
}
ko.mapping.fromJS(data, mapping ,
this
);
}
function
SubViewModel(
var
self =
this
;
ko.mapping.fromJS(data, mapping ,
self
);
self.CategoryMultiSelect:
function
(container, options) {
$(
'<input data-bind="value:'
+ options.field +
'"/>'
)
.appendTo(container)
.kendoMultiSelect({
autoBind:
false
,
dataTextField:
"Type"
,
dataValueField:
"Id"
,
dataSource: options.model.CategoryTypes
});
}
}
ko.applyBindings(mainViewModel, $(
"#MainViewModel"
)[0]);
<
div
id
=
"subviewModelGrid"
data-bind="kendoGrid: {
data: $data.SubViewModels,
sortable: true,
scrollable: false,
editable: true,
pageable: { pageSize: 10, input: false },
columns: [{
field: 'CategoryIds',
title: 'Categories',
width: '300px',
editor: $data.CategoryMultiSelect
}]}"/>
Uncaught TypeError: Object f7ae02dc-c8a7-f112-e043-991018ace7d8 has no method
'get'
kendo.web.min.js:12
S.widget.value.m.extend.refresh kendo.web.min.js:12
F.extend.bind kendo.web.min.js:11
v.extend.applyBinding kendo.web.min.js:12
v.extend.bind kendo.web.min.js:12
o kendo.web.min.js:11
o kendo.web.min.js:11
o kendo.web.min.js:11
s kendo.web.min.js:11
d.extend.refresh kendo.web.min.js:22
d.extend.init kendo.web.min.js:22
(anonymous function) kendo.web.min.js:9
p.extend.each jquery-1.8.2.min.js:2
p.fn.p.each jquery-1.8.2.min.js:2
e.fn.(anonymous function) kendo.web.min.js:9
T.extend.editCell kendo.web.min.js:17
r.incell.r.update.n.wrapper.on.on.n.timer kendo.web.min.js:17
p.
event
.dispatch jquery-1.8.2.min.js:2
g.handle.h
<% var navAuthorization = Telerik.Web.Mvc.Infrastructure.ServiceLocator.Current.Resolve<
Telerik.Web.Mvc.Infrastructure.INavigationItemAuthorization
>(); %>
@{
Layout = null;
}
@model IEnumerable<
Nop.Plugin.Other.Rewards.Models.ReferralProgramModel
>
@(Html.Kendo().Grid((IEnumerable<
Nop.Plugin.Other.Rewards.Models.ReferralProgramModel
>)Model)
.Name("kendoGrid")
.Columns(columns =>
{
//columns.Bound(p => p.Id).Width(0).Hidden();
columns.Bound(p => p.Name).Width(100).Title("Name");
//columns.Bound(p => p.ReferralDiscount).Width(20).Title("Friend Discount");
//columns.Bound(p => p.DiscountEventsPerReferral).Width(100).Title("Discounts per Referral");
columns.Bound(p => p.PointsAwardPerReferral).Width(100).Title("Points Reward on referral");
columns.Bound(p => p.MinimumPurchaseForAward).Width(100).Title("Min Purchase Amt");
//columns.Bound(p => p.RewardEventsPerReferredFriend).Width(100).Title("Discount Events");
//columns.Bound(p => p.CookieLifespan).Width(100).Title("Cookie Lifespan");
columns.Bound(p => p.InsertDateUtc).Format("{0:d}").Width(100).Title("Insert Date");
columns.Command(command => command.Edit());
columns.Command(command => command.Destroy());
})
.Editable(editable => editable.Mode(GridEditMode.PopUp)) //.TemplateName("ReferralEditForm")
.Pageable(pager => pager.PageSizes(new[] { 5, 10, 20, 50 }))
.Sortable()
.Selectable()
.Filterable()
.DataSource(dataSource => dataSource
.Ajax()
.Model(model => {
model.Id(p => p.Id);
model.Field(p=>p.Id).Editable(false);
})
.Read(read => read.Action("GetReferralPrograms", "Referrals"))
.Update(update => update.Action("UpdateRefferalProgram", "Referrals"))
.Destroy(destroy => destroy.Action("DeleteReferralProgram", "Referrals"))
.Create(create => create.Action("CreateReferralProgram", "Referrals"))
)