2014-12-03 40 views
0

我有一個可編輯的gxt樹網格,現在問題是隻有某些行必須是可編輯的。一些護目鏡後,我能找到這個東西。我正在使用內嵌編輯器gxt網格中的條件編輯

editing.addBeforeStartEditHandler(new BeforeStartEditHandler<RevenueGrossBean>() { 

      @Override 
      public void onBeforeStartEdit(
        BeforeStartEditEvent<RevenueGrossBean> event) { 

                //how to acess the model bean that is about to be edited 
               //hw to prevent the edit action from completion 

      } 
     }); 

有沒有辦法實現這一目標?

+0

我不知道它會工作,但訪問模型bean是要進行編輯,你可以嘗試這樣來實現:'yourGridStore.get(事件.getEditCell()。getRow());' – RadASM 2014-12-08 20:10:25

+0

@RadASM這個邏輯對普通網格來說工作得很好,因爲這是一個我們無法依賴的樹形網格'event.getEditCell()。getRow()' – MeanMan 2014-12-16 11:54:27

回答

1

可以通過選擇模型

editing.addBeforeStartEditHandler(new BeforeStartEditHandler<RevenueGrossBean>() { 

       @Override 
       public void onBeforeStartEdit(
         BeforeStartEditEvent<RevenueGrossBean> event) { 

      //how to acess the model bean that is about to be edited 
      RevenueGrossBean bean = event.getSource().getEditableGrid() 
         .getSelectionModel().getSelectedItem(); 
      //hw to prevent the edit action from completion 
      event.setCancelled(true); 



       } 
      }); 
+0

這個方法是有點不安全,因爲這取決於用戶是否真正地選擇了一行,但如果用戶不是點擊他或她用Tab鍵導航網格,你會發現一個錯誤,你會得到不同的結果。您可以使用:YourBean = event.getSource()。getEditableGrid()。getStore()。get(event.getEditCell()。getRow())獲得更好的結果。 – Euclides 2016-09-27 22:05:04