1. #1
    Sencha User
    Join Date
    Jun 2014
    Posts
    4
    Vote Rating
    0
    quande.ren is on a distinguished road

      0  

    Default How to disble a ButtonCell in a Grid based on some condition?

    How to disble a ButtonCell in a Grid based on some condition?


    I have a ButonCell in a Grid. I want the button to be disabled or enabled based on some conditions,. some code like following. I am wandering if it is possible to do so?

    Code:
     
    ColumnConfig column = ... 
    ButtonCell deleteButton=new ButtonCell(){     
        @Override     
        public void render(Context context, String value, SafeHtmlBuilder sb) {         
            super.render(context, value, sb);         
            int rowIndex = context.getIndex();         
            MyRecord myrecord=view.getListStore().get(rowIndex);         
            if(myrecord.getLocked()){             
                disable();         
            }     
        } 
    }; 
    deleteButton.addSelectHandler(new SelectHandler() {     
        @Override     
        public void onSelect(SelectEvent event) {         
        //should only be called when buttonCell is enabled.      
        } 
    }); 
    column.setCell(deleteButton); 
    column.setSortable(true); 
    columnList.add(column);

  2. #2
    Sencha User
    Join Date
    Jun 2014
    Posts
    4
    Vote Rating
    0
    quande.ren is on a distinguished road

      0  

    Default


    I have a ButonCell in a Grid. I want the button to be disabled or enabled based on some conditions,. some code like following. I am wandering if it is possible to do so?
    Code:
      ColumnConfig column = ...  ButtonCell deleteButton=new ButtonCell(){      	@Override      	public void render(Context context, String value, SafeHtmlBuilder sb) {          		super.render(context, value, sb);          		int rowIndex = context.getIndex();          		MyRecord myrecord=view.getListStore().get(rowIndex);          		if(myrecord.getLocked()){              			disable();          		}      	}  };  deleteButton.addSelectHandler(new SelectHandler() {      	@Override      	public void onSelect(SelectEvent event) {          	//should only be called when buttonCell is enabled.       	}  });  column.setCell(deleteButton);  column.setSortable(true);  columnList.add(column);

Tags for this Thread