2017-10-02 7 views
0

私は本当にこれについていくつかのアイデアが必要です。基本的には、ボタンをクリックしてリストを並べ替える作業をしています。上のボタンをクリックすると、選択したリストのインデックスが1つ減っていくリストが表示されます。そして、私が下のボタンをクリックすると、リストが下がり、選択されたリストのインデックスが1つ増えます。私は、選択したリストを一時的に削除し、ユーザーに応じて別のインデックスにリストを挿入する方法を使用しました。私は除去部分を解決しましたが、私は挿入部分については全く考えていません。助けてください。sencha touchリストの異なるインデックスに削除されたリストの行を追加します

これは、選択したリストを削除するコードです。

var removeSelectedItems = Ext.getCmp( 'SearchRefSlipMain_List')。getSelection()[0]; Ext.getCmp( 'SearchRefSlipMain_List')。getStore()。remove(removeSelectedItems);

残ったのは、削除されたリストの行を、別の行(別のインデックス)にユーザーに応じて挿入することだけです。

答えて

0

通常、リストを変更するのではなく、リストを満たすストアを変更します。 この問題が解決しない場合は、セットアップここフィドルことができます:

https://fiddle.sencha.com/#view/editor

(ちょうどそれを保存して、問題のフィドルへのリンクを追加)

私が持っている必要がありますあなたの答えを、変更を同じ結果が、道より速く:

function RowDown() { 
    var direction = 1, // 1 or -1 
     treatmentDetail = Ext.getCmp('Settings_SetTreatmentList_TreatmentDetail_List'), 
    // or use reference 
    // treatmentDetail = this.lookup('Settings_SetTreatmentList_TreatmentDetail_List'), 
     record = treatmentDetail.getSelection()[0], //list id 
     store, index; 

    if (!record) { 
     return; 
    } 

    store = treatmentDetail.getStore(), 
    index = store.indexOf(record); 


    index = index + (1 * direction); 

    if (index >= store.getCount() || index < 0) { 
     return 
    } 

    store.remove(record); 
    store.insert(index, record); 
} 
+0

私は解決策を見つけました。ありがとうbtw =) – AFZ

+0

あなたの解決策をここに残しておくとよいでしょう。他の人があなたの質問を助けてくれたとしたら、その解決策があるはずです。 – Dinkheller

+0

ここで私の答えは=) – AFZ

0

ボタン:

 { 
      xtype: 'button', 
      iconCls: 'arrow_down', 
      handler: function() { 
       RowDown(); 

      } 
     } 

これは、関数である:

function RowDown(){ 

var direction = 1 // 1 or -1  
var record = Ext.getCmp('Settings_SetTreatmentList_TreatmentDetail_List').getSelection()[0]; //list id 


if (!record) { 
    return; 
} 
var index = Ext.getCmp('Settings_SetTreatmentList_TreatmentDetail_List').getStore().indexOf(record); 


if (direction < 0) { 
    index--; 
    if (index < 0) { 
     return; 
    } 
} else { 
    index++; 
    if (index >= Ext.getCmp('Settings_SetTreatmentList_TreatmentDetail_List').getStore().getCount()) { 

     return; 
    } 
} 

Ext.getCmp('Settings_SetTreatmentList_TreatmentDetail_List').getStore().remove(record); 
Ext.getCmp('Settings_SetTreatmentList_TreatmentDetail_List').getStore().insert(index, record); 

} 

***選択したリストを上に移動すると、方向を変える= -1 * https://www.sencha.com/forum/showthread.php?48472-how-to-move-the-grid-s-row-up-and-down (私はここから解決策を得たが、ちょうど煎茶タッチに応じてビットを変更)

+0

あなたの結果をスピードアップする方法を示すために、自分の答えを更新しました。 – Dinkheller

関連する問題