【问题标题】:Smartclient GWT making a ListGridRecord field editable using a custom DataSourceSmartclient GWT 使用自定义 DataSource 使 ListGridRecord 字段可编辑
【发布时间】:2011-01-12 19:29:20
【问题描述】:

我们正在使用 SmartClient GWT 库(请参阅 Smartclient GWT showcase here)。

我正在尝试制作一个 ListGrid UI,当您单击记录时,字段变得可编辑。就像例子一样:

不同之处在于我使用自己的自定义 GWT RPC 服务并手动将 ListGridRecord 添加到我自己的数据源中,我看到我的记录出现了,但单击时这些字段不可编辑。我使用GWTRPCDataSource implementation 创建了一个自定义数据源并正确覆盖了executeFetch 方法。

使用创建 ListGridRecords 的示例 XML 数据源是否正在进行一些特殊处理,将其正确设置为可编辑?

例如,我使用 CountryXMLDS.java 就像示例一样,只是我添加了一条自定义记录(并且我已经删除了所有字段,但我希望可编辑的人口字段除外)。我看到我的记录出现了,但单击记录时该字段不可编辑。

    ListGridField populationField = new ListGridField("population", "population");
    populationField.setType(ListGridFieldType.INTEGER);
    populationField.setCanEdit(true);

   countryGrid.setFields( populationField);

    countryGrid.setCanEdit(true);
    countryGrid.setEditEvent(ListGridEditEvent.CLICK);


    ListGridRecord record = new ListGridRecord();
    record.setAttribute("population", "5");
    CountryXmlDS.getInstance().addData(record);

【问题讨论】:

  • 它似乎在我的机器上正常工作,您能否提供有关您的 countryGrid 的更多详细信息?您使用哪个版本的 smartgwt? populationField.setCanEdit(true) 不是强制性的。

标签: javascript data-binding gwt datasource smartgwt


【解决方案1】:

无论问题是什么,都不在于您分享的详细信息。请尝试以下步骤:

  1. 确保您使用 DataSource 在 ListGrid 上调用 setDataSource()

  2. 确保 ListGrid 字段的名称与数据源中的字段匹配。这是区分大小写的

  3. 确保在 DataSource 中声明了 primaryKey。除非有办法识别记录,否则无法保存编辑内容

  4. 在开发者控制台中查找消息

    http://forums.smartclient.com/showthread.php?t=8159#aConsole

  5. shotgun 方法:覆盖 ListGrid.canEditCell() 并返回您想要的任何内容 - 这会覆盖所有声明性设置,如 field.canEdit。

【讨论】:

  • 设置primaryKey似乎是个问题。
猜你喜欢
  • 2018-02-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-02-27
  • 1970-01-01
  • 2012-02-08
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多