So I've got a model passed in like so:
Now in my javascript I take my model and convert:
Now when I call the editor function in the grid:
After click on the column I get the following error:
Which is referring to the only id in the array of 'CategoryIds'. I'm putting this question in Multiselect because I am using editor functions for several other columns and not having this issue. Any thoughts?
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
}]}"/>
After click on the column I get the following error:
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
Which is referring to the only id in the array of 'CategoryIds'. I'm putting this question in Multiselect because I am using editor functions for several other columns and not having this issue. Any thoughts?