2017-10-02 2 views
0

정말 이에 대한 아이디어가 필요합니다. 기본적으로 버튼을 클릭하여 목록을 정렬하려고합니다. 위로 버튼을 클릭하면 목록이 올라가서 선택한 목록의 색인이 하나씩 줄어 듭니다. 그리고 버튼을 클릭하면 목록이 내려 가서 선택한 목록의 색인이 하나씩 증가합니다. 이 방법을 사용하여 선택한 목록을 임시로 제거한 다음 사용자별로 다른 색인에 목록을 삽입합니다. 나는 제거 부분을 정착 시켰지만, 삽입 부분에 대해서는 전혀 모른다. 도와주세요.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

관련 문제