2011-07-05 16 views
3

コンボボックスの項目をストアからロードしていますが、ユーザーがコンボボックスの項目リストをクリックして表示するとどうなりますか?ストアプロキシからデータを再ロードする必要があります。これにより、リストが点滅して選択されなくなり、ユーザーは別の時間にドロップダウンをクリックするようになります。コンボボックスの項目をEXTjsであらかじめロードする

ステップ1(ページロードで):

Page is loaded, combo not visible, but firebug shows priorities is already loaded

、それを編集するセルをクリック:

コンボボックスの下矢印をクリック

cell is clicked to edit, combo box now visible, firebug shows no changes

。再び、このajax呼び出しはコンボボックスを強制的に自動的に閉じるようにし、ユーザーに強制的に下矢印をクリックさせます。

down arrow on dropdown clicked, firebug shows another ajax call was made.

ビュー

Ext.define('AM.view.card.BacklogList', { 
    extend: 'Ext.grid.Panel', 
    alias: 'widget.backlogcardlist', 

    title: 'Backlog', 
    store: 'BacklogCards', 

    selType: 'cellmodel', 
    plugins: [ 
     Ext.create('Ext.grid.plugin.CellEditing', { 
      clicksToEdit: 1 
     }) 
    ], 

    columns: [ 
     { header: 'ID', dataIndex: 'id' }, 
     { header: 'Name', dataIndex: 'name', field: 'textfield' }, 
     { 
      header: 'Priority', 
      dataIndex: 'priority_id', 
      renderer: function(value){ 
       if (value==3) 
       { 
        return "L"; 
       } 
       else if (value==2) 
       { 
        return "M"; 
       } 
       else 
       { 
        return "H"; 
       } 
      }, 
      width: 130, 
      field: { 
       xtype: 'combobox', 
       typeAhead: true, 
       store: 'Priorities', 
       displayField: 'name', 
       valueField: 'id', 
       listClass: 'x-combo-list-small' 
      } 
     } 
    ] 

}); 

店: "ローカル":私はあなたが設定されているqueryModeを行うために必要なものと考えてい

{ 
    success: true, 
    priorities: [ 
     { 
      id    : 1, 
      name   : "High", 
      short_name  : "H" 
     }, 
     { 
      id    : 2, 
      name   : "Medium", 
      short_name  : "M" 
     }, 
      { 
      id    : 3, 
      name   : "Low", 
      short_name  : "L" 
     } 
    ] 
} 
+0

* queryMode * 'local'、* autoLoad * trueを使用していることを確認し、コンボにアタッチする前にストアをインスタンス化するようにしてください。それはエンドユーザーに表示する前に強制的に値を取得する必要があります。 –

+0

ねえツイストした梨!情報をありがとう! querymodeをローカルに設定することがトリックでした!あなたが答えとしてそれを提出するなら、私はそれをできるだけ早く受け入れるでしょう:) – Robodude

答えて

8

Ext.define('AM.store.Priorities', { 
    extend: 'Ext.data.Store', 
    model: 'AM.model.Priority', 
    autoLoad: true, 

    proxy: { 
     type: 'ajax', 
     api: { 
      read: 'app/data/priorities.json', 
      update: 'app/data/updateUsers.json' 
     }, 
     reader: { 
      type: 'json', 
      root: 'priorities', 
      successProperty: 'success' 
     } 
    } 
}); 

priorities.json第一にeコンボボックスフィールドの設定。

the Ext JS Combobox API documentation (emphasis added)から
field: { 
xtype: 'combobox', 
queryMode: 'local', 
typeAhead: true, 
store: 'Priorities', 
displayField: 'name', 
valueField: 'id', 
listClass: 'x-combo-list-small' 
} 

queryModeで

: 'リモート'、コンボボックスには、動的にユーザーとの対話に基づいてそのストアをロードします。

これは通常、「オートコンプリート」タイプの入力に使用され、ユーザーが入力を完了した後、ストアがロードされます

あなたは店舗のautoLoadをtrueに設定しています。つまり、作成時にデータがすでに店舗内にあるため、ローカルのqueryModelに問題があってはいけません。私はその行動を説明するのに十分なほど掘り下げていないと言うでしょう、誰かがコンボボックスの複雑さを詳しく説明するかもしれません。

関連する問題