I've got a datasource for a combobox working with a local variable passed in the read function so that whenever the variable gets changed the read is called again and the datasource is updated properly like so:
transport: {
read: function (operation) {
var url = "/api/read/Locations/"
$.getJSON(url, { guid: thisGUID }, function (json) {
operation.success(json);
});
I'd like to make this a little more generic, so I can include the control in various scripts and pass the parameter to the read function ala .read({ guid: thisGUID}). Also, I feel like this ought to work the same way as the call above:
read:
url: "/api/read/Locations/",
data: { guid: thisGUID }
But it doesn't seem to. Do I need to declare something in the parametermap to get this to work? I can't seem to pass that local variable to the datasource in the read no matter what I do.
transport: {
read: function (operation) {
var url = "/api/read/Locations/"
$.getJSON(url, { guid: thisGUID }, function (json) {
operation.success(json);
});
I'd like to make this a little more generic, so I can include the control in various scripts and pass the parameter to the read function ala .read({ guid: thisGUID}). Also, I feel like this ought to work the same way as the call above:
read:
url: "/api/read/Locations/",
data: { guid: thisGUID }
But it doesn't seem to. Do I need to declare something in the parametermap to get this to work? I can't seem to pass that local variable to the datasource in the read no matter what I do.
Follow up question. If the datasource is tied to a combobox, how can you pass an initial parameter on the declaration? It reads the dataSource right away, and I'm not sure how to pass a "foo:" variable that way, e.g.:
$("#testCombo").kendoComboBox({
dataTextField: "TextField",
dataValueField: "DataValue",
valuePrimitive: true,
dataSource: new kendo.data.DataSource({
transport: {
read: function(operation) {
alert(operation.data.foo);
operation.success([]);
}
}
}),