How to make cell as non editable based on another cell value in Editable Grid in gxt

后端 未结 3 1727
不知归路
不知归路 2020-12-21 05:54

Hi I am creating Editable Grid using GXT 2.2.3. I created columns like below:

   List eventList=new ArrayList();
    eventList.ad         


        
3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-21 06:59

    How to make cell as non editable based on another cell value in Editable Grid in gxt.

    Try with BeforeEdit listener and call event.setCancelled(true) on the basis of your condition to disable the editing.

    There is no need to disable/enable the cell. Just stop editing in current cell based on condition.

    Sample code:

        grid.addListener(Events.BeforeEdit, new Listener>() {
            public void handleEvent(GridEvent be) {
    
                // disable 2nd cell based on value of 1st cell
                ModelData data = be.getModel();
                String val = data.get("event"); // read 1st cell value
                if (val.equalsIgnoreCase("Remove Attendance")) {
                    if (be.getColIndex() == 2) { // disable 2nd cell only
                        be.setCancelled(true);// Disable edition
                    }
                }
            }
        });
    

    Please have a look at complete sample code.

提交回复
热议问题