【问题标题】:Extjs 5/6: event to fire when an item is selected among the already selected items in the tagfieldExtjs 5/6:在标签字段中已选择的项目中选择项目时触发的事件
【发布时间】:2017-01-05 10:42:17
【问题描述】:

我有一个标签字段可以从商店中多选商品。我想检测所有选定项目中的一个,我单击并突出显示选定值之一。

这是附上的小提琴

https://fiddle.sencha.com/#fiddle/17or

【问题讨论】:

    标签: extjs extjs5 extjs6


    【解决方案1】:

    不知道,但应该很容易找到:

    • 如果查看生成的标记,会发现所选项目的类为 x-tagfield-item-selected
    • 如果您在 ExtJS 代码库中搜索 tagfield-item-selected,会发现 tagSelectedClsExt.baseCSSPrefix + 'tagfield-item-selected'
    • 如果你在ExtJS代码库中搜索tagSelectedCls,发现它在xtemplate中被使用:

          me.multiSelectItemTpl = new Ext.XTemplate([
              '<tpl for=".">',
                  '<li data-selectionIndex="{[xindex - 1]}" data-recordId="{internalId}" class="' + me.tagItemCls + childElCls,
                  '<tpl if="this.isSelected(values)">',
                  ' ' + me.tagSelectedCls,
                  '</tpl>',
      

      其中有一个函数isSelected:

      isSelected: function(rec) {
          return me.selectionModel.isSelected(rec);
      },
      
    • me.selectionModel 引用的 selectionModel 是 ExtJS 的标准选择模型,因此它可能有一个事件 selectionchange。让我们试试吧:

      var tagfield = Ext.create('Ext.form.field.Tag', {
      ...
      });
      tagfield.selectionModel.on('selectionchange',function() {console.log('selectionchange')});
      

      工作。

    【讨论】:

    • 谢谢..太棒了!! :)
    • 我有一个后续问题,假设我想在每个选定的项目上显示工具提示,我该怎么做?
    猜你喜欢
    • 2011-11-21
    • 1970-01-01
    • 2021-06-27
    • 1970-01-01
    • 2019-04-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多