2014-12-03 79 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