This is a common problem, but i dont know how to figure it out with KendoUI widgets and Javascript. I have a KendoGrid whose datasource is coming from an AJAX call to a Web Services. Data is bound to the columns. Two columns (Source and Destination) are two drop down lists:
Each column is defined as
if (stringStartsWith(colTitle, 'Source')) {
columns.push({
field: dataItem.replace(/\s+/g, ''),
title: colTitle,
width: 150,
locked: false,
editor: sourceDropDownEditor,
//template: "#=SourcetankIdentifier#",
attributes: { style: "text-align: left" },
type: "text"
});
}
And the SourceDropDownEditor is as follow:
function sourceDropDownEditor(container, options) {
$('<input id="sourcesDropDownList" required data-text-field="Source" data-value-field="Source" data-bind="value:' + options.field + '"/>')
.appendTo(container)
.kendoDropDownList({
dataTextField: "Source",
dataValueField: "Source",
dataSource: Sources
});
}
The same is done for the Destination Drop Down List.
Now, what i want is, when the user clicks into the Edit button (Grid is defined with In-Line Edit) and choose a certain Source Value from the Source DDL; the list into the Destination DDL must change according to this value.
I wrote a function for retrieving the correct list, depending from the value chosen in the Source DDL. But what i CANNOT do, is to get the Destion DLL of THAT row and to set the Datasource accordingly.
More Details as requested:
Grid is built dynamically:
function generateGrid(JSONData) {
var model = generateModel(JSONData, selectedMenu);
var columns = generateColumns(model);
var data = generateData(gridData, columns);
var grid = $("#mainGrid").kendoGrid({
edit: function (e) {
..
},
dataSource: {
data: data,
schema: {
model: model
},
sort: {
field: defaultSort.replace(/\s+/g, ''),
dir: "desc"
}
},
toolbar: [
..
],
columns: columns,
editable: "inline",
sortable: true,
resizable: true,
filterable: true,
selectable: "multiple",
cancel: function(e) {
$('#mainGrid').data('kendoGrid').dataSource.cancelChanges();
},
KENDO DOJO
Here dojo.telerik.com/uXeKa . It reflects basically the grid template and the column fields
FINAL SOLUTION
Final solution is here: dojo.telerik.com/uXeKa/2 . Don't need to add anything into the Edit function of the Grid. Just need to implement onChange function of the Source DDL, and to set the datasource of the destination.