2014-10-03 27 views
0

我网这样 enter link description hereGXT_GWT添加听者的复选框单元格

我有很多的复选框列的网格,这些复选框反映了我 数据模型的某些特性(真/假)..我怎样才能添加监听每个复选框并在点击时执行一些操作?我想选择复选框时listDatas设定值.. 它不selectionModel设置

我想设置值(true/false)的选中的复选框,当...。例如:我有一个模型(字符串名称,年龄,布尔单,布尔室内,布尔...)每个布尔是一个checkBox列...所以我需要改变模型的值,当用户点击checkBOX - >所以我可以改变listDatas更新数据库

 listStore = new ListStore<DeleteAllTestModel>(); 

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

帮帮我吧!非常感谢

+0

我不明白是什么你正在尝试......你只是试图更新数据库中的布尔值,还是试图根据复选框值的变化采取行动?如果你只是想更新数据库中的值,那么你的'ValueProvider'就会这样做。 – 2014-10-05 18:58:43

回答

0

为了在GXT中做到这一点,您应该使用GXT SelectionModelSelectionChangedHandlerSelectionhandler

下面是两个例子如何使用它: http://www.sencha.com/examples/#ExamplePlace:checkboxgrid http://docs.sencha.com/gxt/3.1.0-beta/ui/grid/SelectionModel.html

而且,这里是我的应用程序的网格选择模型的一个例子的抽象:

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  
    } 
}); 
+0

当checkBox被选中时,我想设置值(真/假)...例如:我有一个模型(字符串名,int年龄,布尔单,布尔室内,布尔....)每个布尔是一个checkBox列...所以我需要改变模型的价值,当用户点击checkBOx – thangdo 2014-10-04 04:28:16

+1

好吧,那么它是'InlineEditingGrid'或'RowEditingGrid'你需要。 http://docs.sencha.com/gxt-guides/3/ui/widgets/grid/edit/GridEditing.html – RadASM 2014-10-05 19:12:34

+0

Thanks @ RadASM ^^ – thangdo 2014-10-06 03:11:51

相关问题