如果我们得到“全部”文本,如何在多选下拉列表中预选值

问题描述

让我告诉你我的要求和我们遵循的方法

我们有一个包含多列的表格(在我们选择一个单元格值的表格中,我们在单元格点击事件中更改下一列的集合)。

为了预选多选下拉列表中的值,我们得到“ALL”键而不是列表 ['a','b','c'],因此显示 ui 'ALL'(字符串格式的文本)但是当我们点击单元格时如何使所有元素在下拉列表中被选中。

在单击单元格(应用于表格)时,我们还更改了列的集合,其中还必须管理“全部”和元素选择。简而言之,我们的列集合会随着单元格的点击事件而不断变化。

   this.columnDeFinitions =[{
            id: 'name',name: 'name <span style="color:red">*</span>',field: 'name',sortable: true,filterable: true,width: 50,formatter: this.customFormatter,editor: {
              model: Editors.multipleSelect,enableRenderHtml: true,collection: ['a','c'],collectionSortBy: {
                property: 'label',sortDesc: false
              },collectionOverride: (finalCollection,args) => {
               // It does not load on initial load
    
               
                return finalCollection;
              },editorOptions: {
                selectAllText: 'ALL',allSelected: 'ALL',okButton: false
              } as MultipleSelectOption
            }
          },{
            id: 'roles',name: 'Role <span style="color:red">*</span>',field: 'Roles',collection: ['1','2','3'],okButton: false
              } as MultipleSelectOption
            }
          }
    ]

    customFormatter(row,cell,value,columnDef,dataContext,grid){
    
        if (value && columnDef.internalColumnEditor.collection.length && Array.isArray(value)
            && value.length === columnDef.internalColumnEditor.collection.length) {
          return 'ALL';
        }
    }

 
    // Change the collections
    onCellClicked(e,args) {
      if (Metadata.columnDef.id === 'name') {
              this.angularGrid.slickGrid.getColumns()[Metadata.cell].internalColumnEditor.collection = ['a','b'];
          } else if (Metadata.columnDef.id === 'roles') {
           
              this.angularGrid.slickGrid.getColumns()[Metadata.cell].internalColumnEditor.collection = ['1','2'];
            
          }
     }

如果您有任何其他解决方案,而不是我们使用的格式化程序和逻辑。 并且在格式化程序函数中,如果您将在表加载事件上打印“dataContext”或行,它仅显示相同的值(例如,第 3 行将被 prinetd 插入“1”、“2”、“3”)。有什么方法可以在格式化程序函数获取所有相应的不同行数或 dataContext。 'this' 在 customFormatter 函数中也不可用。如何获得“this”引用,以便我可以在 customFormatter 函数添加更多自定义逻辑

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)