0

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);
        }
}
Samoth
  • 460
  • 1
  • 11
  • 30

2 Answers2

0

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
})
claudiobosticco
  • 413
  • 2
  • 8
0

Alternatively if you want to disable double click on all boolean fields you could use the following:

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" },
    ]
});

I'm not 100% I understood the question, but if you're looking for a way to allow/disallow the changing of boolean fields take a look at ListGridField.canToggle

stackoverfloweth
  • 6,669
  • 5
  • 38
  • 69