【问题标题】:How to get autocomplete text box value in angularJS with DevExtreme如何使用 DevExtreme 在 angularJS 中获取自动完成文本框值
【发布时间】:2017-01-16 15:50:09
【问题描述】:

尝试提交一个自动完成搜索框,其中包含输入框中的文本。我可以使用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 事件中获取当前值?

【问题讨论】:

    标签: devextreme


    【解决方案1】:

    您似乎正在寻找onEnterKey 事件处理程序:

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

    Demo

    【讨论】:

    • 是的,没错,但我无法从文档中找到 e.component.option("value")。谢谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-01-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-17
    相关资源
    最近更新 更多