Pages

Monday, March 8, 2010

  When creating a new record with Ext.grid.EditorGridPanel and Ext.form.ComboBox

Hi!

When you create a new record that contains a combo box, you should set the value to a empty string in order to avoid getting  . For example.



// My Column Model for the Ext.grid.EditorGridPanel
cm: new Ext.grid.ColumnModel([
{
     header: _("CURRENT_STATUS"),
     dataIndex: 'statusId',
     editor:new Ext.form.ComboBox({
          id: 'currentStatus'+id,
          store: statusStore,
          displayField: 'i18n',
          valueField: 'id',
          typeAhead: true,
          forceSelection:true,
          lazyRender : false,
          triggerAction: 'all',
          selectOnFocus:true
     }),
     renderer: Ext.util.Format.comboRenderer('currentStatus'+id)
}]

...

// My ADD Button

bbar:[
{
     text: _("ADD_BTTN"),
     icon: Constants.ICON_PATH + '/add.png',
     cls: 'x-btn-text-icon',
     tooltip: _("ADD_BTTN_TOOLTIP"),
     handler: function() {
          grid.getStore().insert(0, new Ext.data.Record({"statusId": ""}));
          grid.startEditing(0, 1);
     }
}]


When adding a new record. The combo box will show an empty string

1 comment: