2017-09-29 11 views
0

트리 테이블에 대한 새로 고침 단추를 작성하려고합니다. 새로 고침 작업 (필터 조건이 정의 된 bindrows 메서드 사용) 후에는 이전에 표시된 행을 유지해야합니다. 새로 고침 동작 후에 표시된 행이 사라지는 문제가 있습니다. addEventDelegate()이 적합한 방법인지 확실하지 않습니다.이 방법은 아무런 반응이 없기 때문에, 심지어 디버거를 onAfterRendering() 안에 설정 했더라도 반응하지 않습니다. 누구나이 시나리오를 해결할 수있는 해결책이 있습니까?나뭇 테이블에있는 bindrows() 다음에 표시된 행을 유지하십시오.

onRefresh : function() { 
    var oTreeTable = this.getView().byId("treeTable"); 

    oTreeTable.bindRows({ 
     path: "/TTBL_Set", 
     filters: filterRefresh, 
     parameters: { 
      countMode: "Request", 
      numberOfExpandedLevels: 4 
     } 
    }); 

    oTreeTable.addEventDelegate({ 
     onAfterRendering: function() {    
      oTreeTable.setSelectedIndex(iCurrentSelectedIndex); //iCurrentSelectedIndex is pre-defined 
     } 
    }, this);    
}, 

나무 테이블에 여기에 표시된 행은 enter image description here

+0

누구 아이디어가 있습니까 사용자 정의 데이터 루프를 수신 행을 선택한다? – vincent

답변

0

당신은 Custom Datasap.ui.model.BindingattachDataReceived()

1.Save 선택한 행 컨텍스트를 사용하여 달성 할 수있는 새로 고침 이벤트 후 보관해야 행 선택 메소드 내부의 경로. 데이터 2.After

//inside rowSelectionChange() method 
var oTTable = getYourTable; 
    oCutsData = {}, 
    rowContextPath = oEvent.getSource().getBindingContext().getPath(); 
    if(oTTable && oTTable.data("selectedRows")){ 
     oCustData = oTTable.data("selectedRows");//add your new row selection context path and update the object 
     oCutsData[rowContextPath] = rowContextPath; 
    }else{//for first selection 
     oCutsData = {}; 
     oCutsData[rowContextPath] = rowContextPath;//create new object 
    } 
    oTTable.data("selectedRows",oCutsData); 

다시

var oTTable = this.getView().byId("yourTableID") 
    if(oTTable){ 
     var oRowsBinding = oTTable.getBinding("rows");//Rows Binding 
     oRowsBinding.attachDataReceived(function(oEvent){ 
      var oSelectedRows = oTTable.data("selectedRows"); 
      if(oSelectedRows){ 
       var oModel = getYourModel(); //Tree table model 
       var sPath = null;//only for one selection 
       for(var path in oSelectedRows){ 
        sPath = oSelectedRows[path];      
       } 
       //get the row contexts and compare with the previous selected row and select 
       var oRowContexts = oTTable._getRowContexts(); 
       for(var index in oRowContexts){ 
        if(oRowContexts[index].context.getPath() === sPath){ 
         //Select the table row using row index 
         oTTable.setSelectedIndex(parseInt(index)); 
         break; 
        } 
       } 
       //after the loop destroy the custom data using destroyCustomData() 
       oTTable.destroyCustomData(); 
      } 
     }.bind(this)); 
    } 
+0

감사합니다. 자세한 내용은 @inizio를 참조하십시오. 내 코드에 솔루션을 사용한 후에, 내가 가지고있는'oSelectedRows'의 아웃풋은 선택된 행의 경로이며, 속성 이름 (예 :'/ TTBL_AGGSet (000131) : "/ TTBL_AGGSet (000131)" '). 그리고 결국, 나는 기대했던 행에 대한 나의 선택을 여전히 잃어 버렸다. 따라서 코드에 두 가지 질문이 있습니다. 1. 어떻게 getTheContextPAth()가됩니까? 다음과 같은 메소드 조합을 사용한다는 것을 의미합니까 :'oEvent.getSource(). getBindingContext(). getPath()'? – vincent

+0

2. 필자의 경우 선택은 항상 단일이기 때문에'oSelectedRows'의 결과에는 하나의 값만 포함됩니다. 그렇다면 if 문 안에'oTTable.setSelectedIndex (oSelectedRows.rowContextPath) '라고 써야한다는 뜻입니까? 죄송합니다. 질문이 많습니다. 저는 2 개월의 경험을 가진 초심자입니다. – vincent

+0

1. 네,'oEvent.getSource(). getBindingContext(). getPath()'를 사용해야합니다. 2. 예 if 문에서'oTTable.data ("selectedRows")'를 사용하여 이전에 선택한 행 (경로)을 가져오고 경로를 사용하여 확인란 상태를 나타내는 Model 속성을 업데이트합니다. – inizio