Hello
I am running into a problem using the data field on the transport read. The additionalData function is called only the 1st time the datasource executes read.
I have an event that updates the viewModel and the calls read() on the datasource. I can confirm that it makes a call to the server every time but it only calls additionalData the 1st time.
Here are extracts of the related bits of code.
//in the datasource setup
transport: {
read: {
url: crudServiceBaseUrl + "/NoteSource",
dataType: "json",
data: App.Notes.additionalData(),
cache: false
},
create: {
url: crudServiceBaseUrl + "/Editing_Create",
dataType: "json"
}
}
//in App.Notes
where additionalData is:
additionalData: function () {
console.log("additionalData");
console.log(App.Notes.viewModel.linkedModel());
return { entity: App.Notes.viewModel.linkedModel(), entityId: App.Notes.viewModel.linkedModelId() };
}
in the App.Notes namespace.
and viewModel is:
viewModel: {
linkedModel: ko.observable(""),
linkedModelId: ko.observable(0),
username: ko.observable(""),
noteType: ko.observable(""),
createdAt: ko.observable(new Date())
}
also in the same namespace.
The event handler contains the following that triggers the read and subsequent call to the server:
listView.dataSource.read();
Also just as a side note. This worked when i used the mvc version but I then got a stack overflow when I tried to include a partial of the cshtml page that contains this in my _Layout.
@(Html.Kendo().ListView<TimeTarget.RDM.Core.DataTransferObjects.NoteDto>()
.Name("listView")
.TagName("div")
.ClientTemplateId("template")
.Editable()
.DataSource(dataSource => dataSource
.Model(model => model.Id("NoteId"))
.Create(create => create.Action("Editing_Create", "Note"))
.Read(read => read.Action("NoteSource", "Note")
.Data("App.Notes.additionalData")
) // Specify the action method and controller name
)
.Pageable(paging => paging.Enabled(true))
)
I am running into a problem using the data field on the transport read. The additionalData function is called only the 1st time the datasource executes read.
I have an event that updates the viewModel and the calls read() on the datasource. I can confirm that it makes a call to the server every time but it only calls additionalData the 1st time.
Here are extracts of the related bits of code.
//in the datasource setup
transport: {
read: {
url: crudServiceBaseUrl + "/NoteSource",
dataType: "json",
data: App.Notes.additionalData(),
cache: false
},
create: {
url: crudServiceBaseUrl + "/Editing_Create",
dataType: "json"
}
}
//in App.Notes
where additionalData is:
additionalData: function () {
console.log("additionalData");
console.log(App.Notes.viewModel.linkedModel());
return { entity: App.Notes.viewModel.linkedModel(), entityId: App.Notes.viewModel.linkedModelId() };
}
in the App.Notes namespace.
and viewModel is:
viewModel: {
linkedModel: ko.observable(""),
linkedModelId: ko.observable(0),
username: ko.observable(""),
noteType: ko.observable(""),
createdAt: ko.observable(new Date())
}
also in the same namespace.
The event handler contains the following that triggers the read and subsequent call to the server:
listView.dataSource.read();
Also just as a side note. This worked when i used the mvc version but I then got a stack overflow when I tried to include a partial of the cshtml page that contains this in my _Layout.
@(Html.Kendo().ListView<TimeTarget.RDM.Core.DataTransferObjects.NoteDto>()
.Name("listView")
.TagName("div")
.ClientTemplateId("template")
.Editable()
.DataSource(dataSource => dataSource
.Model(model => model.Id("NoteId"))
.Create(create => create.Action("Editing_Create", "Note"))
.Read(read => read.Action("NoteSource", "Note")
.Data("App.Notes.additionalData")
) // Specify the action method and controller name
)
.Pageable(paging => paging.Enabled(true))
)