Question

I created EditorGrid using GXT 2.2.3.Now I am trying to disable and enable a cell based on the value in another cell i.e. SimpleComboBox.I tried the below code

Listener<GridEvent<AttendanceCaseCreationModel>> gridAfterEditListener = new Listener<GridEvent<AttendanceCaseCreationModel>>() {

        @Override
        public void handleEvent(GridEvent<AttendanceCaseCreationModel> be) {
            AttendanceCaseCreationModel data = be.getModel();
             String val = data.get("event");

             if(val.equalsIgnoreCase("Remove Attendance")){

                data.set("checkinDate","");


                  grid.getColumnModel().getColumnById("checkinDate").getEditor().disable();
                  grid.getStore().update(data); 
                  grid.getView().refresh(true);


             }
             else {
                 data.set("checkinDate",""); 
                 grid.getColumnModel().getColumnById("checkinDate").getEditor().enable();
             grid.getStore().update(data); 
                 grid.getView().refresh(true);

             }

        }
    };
    grid.addListener(Events.AfterEdit, gridAfterEditListener); 

But it's not working for my expectation.Its disabling the entire column and not enabling once it's disabled.

My requirement is to disable and enable the cell based on the another cell value in the EditorGrid of GXT 2.2.3.

No one was able to answer this ?

Was it helpful?

Solution

Instead thinking of disabling and enabling the cell, I just hide and show the cell using CSS. Below is my code which saves me to reach this requirement.

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;

        }
    };
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top