
Ext.namespace('Ext.ux');

Ext.ux.ChoicesCombo = function( config ){
    Ext.apply( this, config );

    Ext.applyIf( this, {
        displayField:   this.name,
        valueField:     this.name,
        hiddenName:     this.name,
        autoSelect:     false,
        typeAhead:      true,
        emptyText:      'Select...',
        triggerAction:  'all',
        selectOnFocus:  true,
        });

    this.triggerAction = 'all';
    this.store = new Ext.data.DirectStore({
        baseParams: {'pk': this.ownerCt.pk, 'field': this.name},
        directFn: this.ownerCt.api.choices,
        paramOrder: ['pk', 'field'],
        reader: new Ext.data.JsonReader({
            successProperty: 'success',
            idProperty: this.valueField,
            root: 'data',
            fields: [this.valueField, this.displayField]
        }),
        autoLoad: true
        });

    Ext.ux.ChoicesCombo.superclass.constructor.call( this );
    };

Ext.extend( Ext.ux.ChoicesCombo, Ext.form.ComboBox, {

    });

Ext.reg( 'choicescombo', Ext.ux.ChoicesCombo );

