0
votes

My Grid like this enter link description here

I have a Grid with many checkboxes columns These checkboxes reflect certain properties of my data Model(True/False)..How can I add a listener to each checkbox and perform some action upon clicking it? i want to set value for listDatas when checkBox is selected.. It is not selectionModel

I want to set value(true/false) when checkBox is checked... .For example: I have a model( String name, int age, boolean single, boolean indoor, boolean....) Each of boolean is a checkBox column... So i need to change value of model when user click checkBOx --> SO i can change listDatas to update database

        listStore = new ListStore<DeleteAllTestModel>();

        List<DeleteAllTestModel> listDatas = getDatas();
        listStore.add(listDatas);
        gridView = new PMTGridDeleteAllTest<DeleteAllTestModel>().getPMTGridDeleteAllTest(listStore);
        gridView.setAutoWidth(true);
        gridView.setStripeRows(true);

Help Me! Many thanks

1
I don't understand what you're trying to do ... are you just trying to update the boolean values in the database, or are you trying to take an action based upon a change in the checkbox value? If you're just trying to update the value in the database then your ValueProvider will do this. - Andy King

1 Answers

0
votes

In order to do this in GXT you should use GXT SelectionModel with SelectionChangedHandler or Selectionhandler.

Here is two examples how to use it: http://www.sencha.com/examples/#ExamplePlace:checkboxgrid http://docs.sencha.com/gxt/3.1.0-beta/ui/grid/SelectionModel.html

Also here is an abstract of an example of my app's grid selection model:

List<ColumnConfig<M, ?>> columnsConfigs = new ArrayList<ColumnConfig<M, ?>>();
IdentityValueProvider<M> identityValueProvider = new IdentityValueProvider<M>();
CheckBoxSelectionModel<M> selectColumn = new CheckBoxSelectionModel<M>(identityValueProvider);
selectColumn.setSelectionMode(Style.SelectionMode.MULTI);
columnsConfigs.add(selectColumn.getColumn());
columnsConfigs.addAll(cm.getColumns());
this.cm = new ColumnModel<M>(columnsConfigs);
this.setSelectionModel(selectColumn);
this.getSelectionModel().addSelectionChangedHandler(new SelectionChangedEvent.SelectionChangedHandler<M>() {
    @Override
    public void onSelectionChanged(SelectionChangedEvent<M> event) {
        // TODO whatever you have to do    
    }
});