没有editMode的SmartClient ListGrid boolen字段(双击)

时间:2016-09-29 07:07:39

标签: smartclient

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

我需要做的就是为布尔字段禁用editMode(禁用双击)并仍然启用正常的一键式'改变布尔值。

双击应适用于其他列。

有什么想法吗?

我的代码:

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);
        }
}

2 个答案:

答案 0 :(得分:0)

您可以添加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
})

答案 1 :(得分:0)

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

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