Search code examples
smartclient

SmartClient ListGrid boolen field without editMode(double click)


I have smartclient ListGrid with some columns. ListGrid has some text fields with edit mode (double click to enter) and boolean fields.

All I need to do is disable editMode for boolean fields (disable double click) and still enable normal 'one-click' to change boolean value.

Double click should work for other columns.

Any ideas?

My code:

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

Solution

  • You may add recordDoubleClick:"return false" on the boolean field, to prevent the grid-level handler from firing.

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