【问题标题】:GXT_GWT add listner for checkBox cell GridGXT GWT 为复选框单元格网格添加侦听器
【发布时间】:2014-11-28 03:52:59
【问题描述】:

我的网格是这样的 enter link description here

我有一个包含许多复选框列的网格 这些复选框反映了我的某些属性 数据模型(真/假)..如何为每个复选框添加一个侦听器并在单击它时执行一些操作?我想在选中复选框时为 listDatas 设置值。这不是 selectionModel

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

        listStore = new ListStore<DeleteAllTestModel>();

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

帮帮我!非常感谢

【问题讨论】:

  • 我不明白您要做什么...您只是想更新数据库中的布尔值,还是尝试根据复选框值?如果您只是想更新数据库中的值,那么您的 ValueProvider 将执行此操作。

标签: gwt checkbox grid gxt


【解决方案1】:

要在 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    
    }
});

【讨论】:

  • 我想在checkBox被选中时设置值(true/false)...例如:我有一个模型(字符串名称,整数年龄,布尔单,布尔室内,布尔... .) 每个布尔值都是一个复选框列...所以当用户单击复选框时我需要更改模型的值
  • 好的,那么您需要的是InlineEditingGridRowEditingGriddocs.sencha.com/gxt-guides/3/ui/widgets/grid/edit/…
  • 我无法在编辑后更新 listData -> listDatas2 显示以前的数据@@ getListStore().commitChanges(); listDatas2= getListStore().getModels();
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-09-10
  • 1970-01-01
相关资源
最近更新 更多