1

ユーザーが入力した値のエントリがストアにない場合、コンボボックスと関連するストアがあり、すべてが正しいですが、ユーザーがストアにある値を入力すると不快な機能が1つありますが、ユーザーはすぐにそれを行いますストレージに入力値をロードする時間がありませんでした。リセットされます。

ユーザーがストアロードまで待たなかった場合に、別のフォームフィールドに移動したときにユーザーが入力した値をリセットしない方法 (入力された値がストアにある場合)

var bik = new Ext.form.ComboBox({
        store: storeBik,
        displayField: 'BANK_NAME',
        fieldLabel: 'БИК',
        name: 'BIK',
        hiddenName: 'BIK',
        valueField:'BIK',
        typeAhead: true,
        forceSelection:true,
        selectOnFocus:true,
        triggerAction: 'all',
        minChars : 1,
        mode: 'remote'
        resizable : true,
        validator : validBik,
        tpl: new Ext.XTemplate('<tpl for="."><div class="x-combo-list-item"><b>{BIK} </b> {BANK}</div></tpl>')

    });
4

1 に答える 1

1

これが発生する理由は、 をオンにしたためですforceSelection。ぼかしの後ComboBox、型付けされた値に適したレコードをストアで見つけようとします。そのようなレコードが存在しない場合、値がリセットされます。

私は2つの解決策を考えることができます:

  • 消すforceSelection
  • 拡張するComboBox

validBikバリデータが添付されていることがわかりました。クライアント側で値を検証できる場合は、オフforceSelectionにすれば必要なものはすべて揃っています。一方、値を選択するためにストアにデータが本当に必要な場合は、拡張する必要がありますComboBox

以下はComboBox、リクエストが終了するまで値を保持する変更です。完璧ではありませんが、次のことが役立つかもしれません。

var bik = new Ext.form.ComboBox({
    [...],

    // Check if query is queued or in progress
    isLoading: function() {
        return this.isStoreLoading || // check if store is making ajax request
            this.isQueryPending; // check if there is any query pending
    },

    // This is responsible for finding matching record in store
    assertValue: function() {
        if (this.isLoading()) {
            this.assertionRequired = true;
            return;
        }

        Ext.form.ComboBox.prototype.assertValue.apply(this, arguments);
    },

    // this is private method; you can equally write 'beforeload' event handler for store
    onBeforeLoad: function(){
        this.isQueryPending = false;
        this.isStoreLoading = true;

        Ext.form.ComboBox.prototype.onBeforeLoad.apply(this, arguments);
    },

    // catch moment when query is added to queue
    onKeyUp: function(e){
        var k = e.getKey();
        if(this.editable !== false && this.readOnly !== true && (k == e.BACKSPACE || !e.isSpecialKey())){
            this.isQueryPending = true;
        }

        Ext.form.ComboBox.prototype.onKeyUp.apply(this, arguments);
    },

    // this is private method; you can equally write 'load' event handler for store
    onLoad: function() {
        Ext.form.ComboBox.prototype.onLoad.apply(this, arguments);

        this.isQueryPending = false;
        this.isStoreLoading = false;
        if (this.assertionRequired === true) {
            delete this.assertionRequired;
            this.assertValue();
        }
    }
});
于 2013-10-16T10:06:50.317 に答える