We have a kendo grid that lists users with roles in our application. When editing a role we want to bind the kendo combobox editor control using one service method that get's the actual employee record (based on EE #) and bind the combobox to that. When creating a new role we want to dynamically search for the employee to be granted a role which requires a separate service method to pattern match on partial name typed into combobox and return the matches. The first scenario works like a charm when autoBind is set to "true" but for the second scenario it is necessary to have the autoBind set to false so it does not try to fire when the datasource is (re)initialized to point to the appropriate service method. I have this functionality being configured when the "edit" event is fired on the grid and looking to see if I'm dealing with a new model or an existing one to set the datasource as necessary but unfortunately there is no way to set the autoBind to false (via API method) and thus the service method for the "create" functionality is called immediately but errors out because the required filter parameters for the service method are not yet available. Am I missing something or is there truly no way to dynamically set/change the autoBind value?
if
(e.model.isNew() ==
false
) {
// get the empid of the current record being edited
var
empID = e.model.get(
"EmpID"
);
// configure $scope.employeeDataSource
$scope.employeeDataSource =
new
kendo.data.DataSource({
type:
"odata-v4"
,
transport: {
read:
function
(e) {
caoService.getEmployeeFromEmpID(empID).then(
function
(data) {
e.success(data);
})
}
}
})
// set the datasource and call the read method
$(e.container).find(
'[name="EmpID"]'
).data(
"kendoComboBox"
).setDataSource($scope.employeeDataSource);
$(e.container).find(
'[name="EmpID"]'
).data(
"kendoComboBox"
).dataSource.read();
}
else
{
// configure $scope.employeeDataSource
$scope.employeeDataSource =
new
kendo.data.DataSource({
type:
"odata-v4"
,
serverFiltering:
true
,
transport: {
read:
function
(e) {
caoService.findEmployeesByEmployeeName($scope.selectedSector, $scope.employeeName).then(
function
(data) { e.success(data); })
}
}
})
// set the datasource
$(e.container).find(
'[name="EmpID"]'
).data(
"kendoComboBox"
).setDataSource($scope.employeeDataSource);
}