Hello Matt,
The ForeignKey column needs all values for the respective field that will be bound to the dropdown editor. For this reason, I would suggest using a custom editor. You would need to customize it further to match the desired functionality.
I have customized the custom editor demo do show a possible approach. The available values in the DropDownList for selection of a Category would change based on the selection made in a DropDownList, outside of the Grid. In the example, above the Grid, a Kendo DropdownList is available to select the location, for which the data in the grid will be displayed. Upon selection of location the Grid's data is filtered:
function onLocationChange(e){
var location = e.sender.value();
var grid = $("#grid").getKendoGrid();
grid.dataSource.filter({field: "Location", operator: "contains", value: location})
}
For the Grid, you could store the available Categories for each location in a variable with a single call to the server and load the respective categories based on the selection of location. Whenever editing is initiated check whether the field being edited is the Category field, get a reference to the DropDownList and update the dataSource with the available options for that Location.
var categories = ({
Location1:
[{"CategoryID": 1, "CategoryName": "Beverages"},
{"CategoryID": 2, "CategoryName": "Condiments"},
{"CategoryID": 3, "CategoryName": "Confections"}
],
Location2:
[{"CategoryID": 2, "CategoryName": "Condiments"},
{"CategoryID": 3, "CategoryName": "Confections"}
]
})
function onGridEdit(e){
var location = $("#location").getKendoDropDownList().value();
var ddl = e.container.find("[data-role='dropdownlist'][name='Category']").getKendoDropDownList();
if(location == 1){
ddl.dataSource.data(categories.Location1);
} else {
ddl.dataSource.data(categories.Location2);
}
}
A runnable dojo with the above suggestion implemented is available here, for you to review.
I hope the above helps you implement the desired functionality. Let me know if you have any questions.
Regards,
Aleksandar
Progress Telerik