在 Angularjs ui-grid 中捕捉下拉选择变化
Catch dropdown selection changes in Angularjs ui-grid
如何捕捉 ui-grid 中的下拉选择变化。我已经自定义 'ui-grid/dropdownEditor' 像这样
var customCellTemplate = '<div><form name=\"inputForm\"><select ng-class="\'colt\' + col.uid" ui-grid-edit-dropdown ng-model=\"MODEL_COL_FIELD\" ng-change="vm.onDropdownChange(row)" ng-options=\"field[editDropdownIdLabel] as field[editDropdownValueLabel] CUSTOM_FILTERS for field in editDropdownOptionsArray\"></select></form></div>'
在 ui-grid/dropdownEditor 中添加了 ng-change="vm.onDropdownChange(row)" 但未触发 onDropdownChange 事件。
我的控制器看起来像这样
function Controller(){
vm.onDropdownChange = onDropdownChange;
vm.gridOption.columnDefs = [
{
field: 'staus', displayName: 'Status', editableCellTemplate: customCellTemplate, width: '20%',
cellFilter: status filter, editDropdownIdLabel: 'status_id', editDropdownValueLabel: 'status', editDropdownOptionsArray: statusArray
},
{
//Other fileds
}];
function onDropdownChange(row){
}
}
请告诉我哪里出错了以及如何实现此功能。
您需要使用 appScope 来触发您的函数。
看看here
grid.appScope.onDropdownChange();
如何捕捉 ui-grid 中的下拉选择变化。我已经自定义 'ui-grid/dropdownEditor' 像这样
var customCellTemplate = '<div><form name=\"inputForm\"><select ng-class="\'colt\' + col.uid" ui-grid-edit-dropdown ng-model=\"MODEL_COL_FIELD\" ng-change="vm.onDropdownChange(row)" ng-options=\"field[editDropdownIdLabel] as field[editDropdownValueLabel] CUSTOM_FILTERS for field in editDropdownOptionsArray\"></select></form></div>'
在 ui-grid/dropdownEditor 中添加了 ng-change="vm.onDropdownChange(row)" 但未触发 onDropdownChange 事件。
我的控制器看起来像这样
function Controller(){
vm.onDropdownChange = onDropdownChange;
vm.gridOption.columnDefs = [
{
field: 'staus', displayName: 'Status', editableCellTemplate: customCellTemplate, width: '20%',
cellFilter: status filter, editDropdownIdLabel: 'status_id', editDropdownValueLabel: 'status', editDropdownOptionsArray: statusArray
},
{
//Other fileds
}];
function onDropdownChange(row){
}
}
请告诉我哪里出错了以及如何实现此功能。
您需要使用 appScope 来触发您的函数。
看看here
grid.appScope.onDropdownChange();