XPages Dojo数据网格和自定义REST服务 [英] XPages Dojo Data Grid and Custom REST Service
问题描述
可以将定制的REST服务用作dojo数据网格的数据源吗?我需要将来自三个不同数据库的数据合并到一个数据网格中。列数据将需要是可排序的。 REST服务的响应看起来是正确的。我在将JSON数据绑定到dojo网格列时遇到麻烦。
Can a custom REST service be used as a data source for a dojo data grid? I am needing to combine data from three different databases into one data grid. The column data will need to be sort-able. The response from the REST service looks to be correct. I have having trouble with binding the JSON data to the dojo grid columns.
推荐答案
非常有趣-我测试并使用自定义REST服务看到了同样的东西-被引用时不起作用作为网格的storeComponentId。
Very interesting -- I tested and saw the same thing with a custom REST service -- it doesn't work when referenced as the storeComponentId of the grid.
我可以执行以下步骤:
- 在页面资源中包括两个dojo模块以设置数据存储
- 带有代码的pass-thru脚本标记,用于为网格设置JSON数据存储(使用资源指定的dojo模块)
- 网格的store属性设置为在标签中为数据源设置的变量。 (storeComponentId需要XPages组件名称)
以下代码段显示了更改:
Here are some snippets that show the changes:
<xp:this.resources>
<xp:dojoModule name="dojo.store.JsonRest"></xp:dojoModule>
<xp:dojoModule name="dojo.data.ObjectStore"></xp:dojoModule>
</xp:this.resources>
...
<xe:restService id="restService1" pathInfo="gridData">
...
<script>
var jsonStore = new dojo.store.JsonRest(
{target:"CURRENT_PAGE_NAME_HERE.xsp/gridData"}
);
var dataStore = dojo.data.ObjectStore({objectStore: jsonStore});
</script>
...
<xe:djxDataGrid id="djxDataGrid1" store="dataStore">
此处有更多信息和完整示例:
There's more information and a full sample here:
http://xcellerant.net/dojo-data -grid-33-reading-custom-rest-service /
这篇关于XPages Dojo数据网格和自定义REST服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!