Reputation: 7015
Scenario : consider we have two view-models use same data source masterDataSource
, and we want to add a detail
entity to master
entity.
Question : how would you pass masterId
as query string to the create method of datasource from those view-models:
var masterDataSource = new kendo.data.DataSource({
transport: {
create: {
url: function() {
return "/api/master/addItem?masterId=" + masterId;//<-- How to pass masterId form view-models
},
dataType: "json",
type: "POST"
},
},
schema: {
model: {
id: "id"
}
}
}
Upvotes: 1
Views: 3546
Reputation: 7015
I found this solution:
var dynamicUrl = "/api/master/addItem?masterId=" + masterId;
masterDataSource.transport.options.read.url = dynamicUrl;
Upvotes: 4