0

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 ?

1
  • No one was able to answer this ? Apr 16, 2014 at 8:28

1 Answer 1

1

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;

        }
    };

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.