【问题标题】:SmartClient ListGrid boolen field without editMode(double click)没有editMode的SmartClient ListGrid布尔字段(双击)
【发布时间】:2016-09-29 07:07:39
【问题描述】:

我有一些列的 smartclient ListGrid。 ListGrid 有一些带有编辑模式的文本字段(双击进入)和布尔字段。

我需要做的就是禁用布尔字段的编辑模式(禁用双击)并仍然启用正常的“一键式”来更改布尔值。

双击应该适用于其他列。

有什么想法吗?

我的代码:

isc.ListGrid.create({
        ID: "ColumnsList",
        saveLocally: true,
        filterLocalData: true,
        alternateRecordStyles: true,
        canReorderRecords: true,
        selectionAppearance: 'rowStyle',
        autoFetchData: false,
        showRollOver: true,
        canRemoveRecords: true,
        deferRemoval: false,
        initWidget: function () {
            this.Super('initWidget', arguments);
            var me = this;

            var fields = [
                {name: 'id', primaryKey: true, required: true, showIf: 'false', canEdit: false, canHide: false},
                {
                    name: 'name',
                    validOperators: [],
                    canEdit: true,
                    canHover: false,
                    canSort: false,
                    title: 'DB Column Name'
                },
                {
                    name: 'primaryKey',
                    validOperators: [],
                    width: '12%',
                    canEdit: true,
                    canHover: true,
                    canSort: false,
                    //canToggle: true,
                    title: 'Primary Key',
                    type: 'boolean',
                    changed: function (form, item, value) {
                        // my logic to allow only one value per column is selected
                    }
                }
            ];
            me.setFields(fields);
        }
}

【问题讨论】:

    标签: smartclient


    【解决方案1】:

    您可以在布尔字段上添加 recordDoubleClick:"return false",以防止触发网格级处理程序。

    isc.ListGrid.create({
        ID: "countryList",
        width:550, height:224, alternateRecordStyles:true,
        // use server-side dataSource so edits are retained across page transitions
        dataSource: countryDS,
        // display a subset of fields from the datasource
        fields:[
            {name:"countryCode", title:"Flag", width:40, type:"image", imageURLPrefix:"flags/16/", imageURLSuffix:".png", canEdit:false},
            {name:"countryName"},
            {name:"continent"},
            {name:"member_g8", recordDoubleClick:"return false"},
            {name:"population"},
            {name:"independence"}
        ],
        autoFetchData: true,
        canEdit: true
    })
    

    【讨论】:

      【解决方案2】:

      或者,如果您想禁用双击所有布尔字段,您可以使用以下内容:

      isc.ListGrid.create({
          rowDoubleClick: function (record, recordNum, fieldNum) {
              if (this.getField(fieldNum).type != "boolean") {
                  this.Super("rowDoubleClick", arguments);
              }
          },
          fields: [
              { name: "isActive", type: "boolean", canEdit: false },
              { name: "firstName", type: "text", canEdit: true },
              { name: "lastName", type: "text", canEdit: true },
          ],
          data: [
              { isActive: false, firstName: "Alex", lastName: "Smith" },
              { isActive: true, firstName: "Jane", lastName: "Monroe" },
          ]
      });
      

      我不是 100% 理解这个问题,但如果您正在寻找一种允许/禁止更改布尔字段的方法,请查看 ListGridField.canToggle

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2020-10-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-02-24
        相关资源
        最近更新 更多