如何从GXT 2.2.3迁移到GXT 3.0.1

时间:2014-04-12 01:45:47

标签: java gwt gxt

我使用GXT 2.2.3创建了EditorGrid。所需的一切都结束了。但是有一点我坚持了,即我需要根据一个单元格中的值禁用和启用一些单元格。我问了这个问题How to make cell as non editable based on another cell value in Editable Grid in gxt 。但我得到的解决方案对我来说并不起作用。我在Sencha,Coderanch和其他一些论坛上问道,但我仍然没有得到解决方案。

现在我决定将其迁移到GXT 3.0.1。

我需要一个EditableGrid,需要根据另一个Cell中的值禁用和启用单元格编辑。请在GXT 3.0.1中建议哪个网格适合这个,以及如何迁移到GXT 2.2.3到GXT 3.0。 1。

2 个答案:

答案 0 :(得分:0)

我不使用gxt 2.x.x.我的朋友尝试从2迁移到3.他使用2和3并行。所以他开始使用gxt3构建一个新页面,因为如果你混合它们,你可能会遇到布局的大问题! 如果你想使用gxt3,你应该做这样的声音:

//Create grid
Grid<Plant> grid = new Grid(...);
//Create editable grid
GridEditing<Plant> editing = new GridInlineEditing<Plant>(editableGrid);

//add first editing column
TextField watchField = new TextField();
TextField targerField = new TextField();

watchField.addChangeHandler(new ChangeHandler() {
   @Override
   public void onChange(ChangeEvent event) {
      if(smtng) targerField.disable();
      else targetField.enable();
   }
}); 
editing.addEditor(cc1, watchField);
editing.addEditor(cc2, targetField);

所以我认为那可以帮到你。

答案 1 :(得分:0)

我只使用CSS解决了这个问题。考虑禁用和启用单元格,我只是隐藏并使用CSS显示单元格。以下是我的代码,可以帮助我满足这一要求。

 GridCellRenderer<AttendanceCaseCreationModel> checkinRenderer=new GridCellRenderer<AttendanceCaseCreationModel>() {

        @Override
        public Object render(AttendanceCaseCreationModel model, String property,
                ColumnData config, int rowIndex, int colIndex,
                ListStore<AttendanceCaseCreationModel> store,
                Grid<AttendanceCaseCreationModel> grid) {

            String color="pink";
            if(eventcombo.getValue()!=null){


                if(eventcombo.getRawValue().equalsIgnoreCase("Forgot To Checkin") || 
                        eventcombo.getRawValue().equalsIgnoreCase("Mark/Modify Attendance")){
                    color="pink";
                }
                else{

                    config.style=config.style+ ";visibility: hidden;";
                }

            }

            config.style=config.style+ ";background-color:" + color  + ";";
            config.style=config.style+ ";display: block;";
            Object value = model.get(property);
            return value;

        }
    };