completeOnTab weirdness

Hi,

I have a ListGrid with a databound combobox. I want to use completeOnTab, so the user can start typing, and then tab on as soon as the correct picklist value is selected.

I implement a changed() event handler for the combobox, and here I call getSelectedRecord() to get the entire DS record for the selected picklist item. I expect getSelectedRecord() to return NULL whenever the user has entered a value not in the picklist. Once a value from the picklist is entered, I get the full DS record and can use it to, say, update other grid cells or whatever.

My problem is that all this works fine if I put the “completeOnTab: true” in the datasource field definition, but NOT if I put it in the ListGrid field definition. I don’t think completeOnTab belongs in a datasource definition..

Below is a complete application illustrating this. Paste it into a feature explorer example, and type ‘f’ in the combo box. The picklist item “foo” is now selected. Hit tab, and the changed event fires and updates the descr field.

To illustrate the problem, comment out the “completeOnTab: true” line in the datasource field definition, and uncomment it in the ListGrid field definition, and then try again. The descr field is not updated, because getSelectedRecord() returns NULL. Is this a bug?

This happens on 7.0RC on my dev system, and in the feature explorer here: http://www.smartclient.com/index.jsp#_Featured.Samples_Hello.World, which I have tried on Windows Vista with browsers Firefox 3.0.10, IE8 and Safari 3.2.3. Same result in all.

isc.DataSource.create({
    ID: "pickListDS",
    fields: [{ name: "model" }, { name: "descr"}],
    clientOnly: true,
    testData: [{model: "foo", descr: "The best foo"},{model: "bar", descr: "The ultimate bar"}
    ]
});

isc.DataSource.create({
    ID:"gridDS",
    fields: [
      {   name: "model",
          primaryKey: true,
          completeOnTab: true,                     // <---- remove this line..
          canEdit: true
      },
      {   name: "descr",
          canEdit: false
      }
    ],
    clientOnly: true
});

isc.ListGrid.create({
    ID: "orderLinesGrid",
    dataSource: gridDS,
    listEndEditAction: "next",
    fields: [
    {
        name:"model",
        editorType: "comboBox",
        optionDataSource: "pickListDS",
        //completeOnTab: true,                     // <---- ..and add this line
        changed: function(form, item, value) {
            var rec = this.getSelectedRecord();
            if(rec != null)
                item.grid.setEditValue(item.rowNum, item.grid.getFieldNum('descr'), rec.descr);
        }
    },
    { 
        name:"descr"
    }
    ]
});

orderLinesGrid.startEditingNew();

When specifying the settings for an editor in a ListGrid field you need to place the settings in the editorProperties attribute. Replace the ListGrid completeOnTab with editorProperties: {completeOnTab: true}, and you get the desired result. DataSource properties are merged into the editorProperties automatically.

Thanks a mil, David. I missed that one. I guess I am overwhelmed by that massive API!

Now it works!

Nilre the n00b :slight_smile: