如何使用DevExtreme

时间:2017-01-16 15:50:10

标签: 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事件中获取当前值?

1 个答案:

答案 0 :(得分:1)

看起来您正在寻找onEnterKey事件处理程序:

$scope.autocompleteOptions = {
    //...
    onEnterKey: function(e) {
        var selectedValue = e.component.option("value");
        DevExpress.ui.notify("Searching for " + selectedValue);
    }
};

Demo