如何使用 DevExtreme 获取 angularJS 中的自动完成文本框值
How to get autocomplete text box value in angularJS with DevExtreme
正在尝试提交一个自动完成搜索框,其中包含在框中键入的文本。我可以使用 onValueChanged
但它会触发每个按键。我需要在按下回车键时进行搜索。我已经尝试了一些事情,但无法解决。这是 dxToolbar 的一部分:
{
location: 'after',
widget: 'dxAutocomplete',
options: {
width: '340px',
placeholder: 'Enter title, category or identifier',
dataSource: PageAutoCompleteDataSource($http),
bindingOptions: {
searchText: 'text'
},
onChange: function(e){
console.log('Value searched ' + $scope.searchText);
DevExpress.ui.notify("Searching for " + $scope.searchText);
}
}
}
不用管数据源等问题。我只需要知道如何在任何 onXX 事件中获取当前值?
您似乎在寻找 onEnterKey 事件处理程序:
$scope.autocompleteOptions = {
//...
onEnterKey: function(e) {
var selectedValue = e.component.option("value");
DevExpress.ui.notify("Searching for " + selectedValue);
}
};
正在尝试提交一个自动完成搜索框,其中包含在框中键入的文本。我可以使用 onValueChanged
但它会触发每个按键。我需要在按下回车键时进行搜索。我已经尝试了一些事情,但无法解决。这是 dxToolbar 的一部分:
{
location: 'after',
widget: 'dxAutocomplete',
options: {
width: '340px',
placeholder: 'Enter title, category or identifier',
dataSource: PageAutoCompleteDataSource($http),
bindingOptions: {
searchText: 'text'
},
onChange: function(e){
console.log('Value searched ' + $scope.searchText);
DevExpress.ui.notify("Searching for " + $scope.searchText);
}
}
}
不用管数据源等问题。我只需要知道如何在任何 onXX 事件中获取当前值?
您似乎在寻找 onEnterKey 事件处理程序:
$scope.autocompleteOptions = {
//...
onEnterKey: function(e) {
var selectedValue = e.component.option("value");
DevExpress.ui.notify("Searching for " + selectedValue);
}
};