- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我正在尝试使用 YUI DataTable 显示以下 JSON 对象。我能够在 YUI 数据表中成功显示 lastName、firstName、startDate、employeeCode、employeeStatus。但是我无法显示内部对象中的值。在列集中,我尝试了 user.userId,它在 DataTable 中显示为 {value}。
[
{
"lastName": "MyLastName",
"firstName": "MyFirstName",
"startDate": "11-11-11",
"employeeCode": "124",
"employeeStatus": "Permanent",
"user": {
"key": {
"name": null,
"parent": {
"name": null,
"parent": null,
"id": 855,
"namespace": "",
"complete": true,
"kind": "Employee"
},
"id": 856,
"namespace": "",
"complete": true,
"kind": "Users"
},
"salt": null,
"userId": "myemail@example.com",
"status": true,
},
{
...
}
]
这是 Javascript 代码:
<script type="text/javascript">
YUI().use("jsonp", 'sortable', 'json-parse', 'datatable', "datatable-sort", "io", "node", function(Y) {
var nestedCols = [
{key : "employeeCode",label : "Employee Code", sortable:true},
{key : "firstName", label : "First Name",sortable: true},
{key : "lastName", label : "Last Name", sortable:true},
{key : "user.userId", label : "Email Id"},
];
Y.io('/Employee/AjaxList', {
on : {
success : function(tx, r) {
var data = Y.JSON.parse(r.responseText);
var table = new Y.DataTable.Base({
columnset : nestedCols,
recordset : data,
}).plug(Y.Plugin.DataTableSort);
table.render("#empTable");
}
}
});
});
</script>
这段代码有什么问题吗?如何在 DataTable 中显示 user.userId 的值?
注意:JSON 是使用 Jackson 生成的,应用程序是在 GAE/J 中开发的
更新:
我按照@Luke 的建议使用了DataSource。这次我得到了一个只有标题的空数据表。这是代码片段。
YUI().use("datasource-get", "datatable-base", "datatable-datasource","datasource-arrayschema", function (Y) {
var url = "/Employee/AjaxList?";
var dataSource, table;
dataSource = new Y.DataSource.Get({ source: url });
dataSource.plug(Y.Plugin.DataSourceArraySchema, {
schema: {
resultFields: ["firstName", "lastName"]
}
});
var cols = ["firstName", "lastName"];
table = new Y.DataTable.Base({
columnset: cols,
});
table.plug(Y.Plugin.DataTableDataSource, { datasource: dataSource });
table.render("#empTable");
table.datasource.load();
});
最佳答案
您需要使用 datasource-jsonschema 来解析嵌套值。请参阅此示例:http://yuilibrary.com/yui/docs/datatable/datatable-dsget.html
您应该能够按照这些步骤操作,将 Y.DataSource.Get 替换为 Y.DataSource.IO
关于javascript - 在 YUI 数据表中显示 JSON 对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7496481/
在过去的两年里,我一直在广泛使用 jQuery 和 ExtJs 进行编程。我认为现在是时候花一些时间来学习令人印象深刻的 YUI 库了。 在从头开始学习方面什么是可取的? 我不打算在我 future
我们使用 YUI3 加载器来管理加载我们的 javascript 和 css 文件。作为每个页面上引导 js 代码的一部分,我们有如下内容: YUI({ ... groups: {
我有一个 YUI 数据表,我将以下数据放入表中: {key:"name", label:"name", editor: nameChoiceEditor}, {key:"group", label
我想向已经包含 Prototype 和 Scriptaculous 的页面添加日历控件。对我能找到的任何原型(prototype)都不满意,我正在考虑使用 YUI 日历小部件。 我这可能会导致什么问题
我可以使用多个下拉菜单和分页的 YUI 数据表来过滤静态数据集的行吗? http://www.mappingbahia.org/project/iguape_dataset.html 最佳答案 每个
关闭。这个问题是opinion-based 。目前不接受答案。 想要改进这个问题吗?更新问题,以便 editing this post 可以用事实和引文来回答它。 . 已关闭 9 年前。 Improv
在我们的 SSL 页面上使用 YUI 脚本会破坏 SSL 连接,因为它们通过 http 连接动态加载来自 yahoo(组合)的脚本。 由于我们只使用 YUI 3 的历史管理器,所以我想将代码托管在我们
我使用以下代码通过 YUI 在页面正文中创建一个 html 元素。此代码不会产生任何错误。 问题是,段落元素没有在 html 页面中创建。 YUI Test
YUI Compressor,在其(不是很广泛的)文档中将其作为一个选项: --disable-optimizations Disable all the built-in micro opt
如果我运行这样的测试用例,我的测试结果将显示在 YUI 测试控制台小部件中: YUI({debug: true}).use('test', 'event-base', 'test-console',
YUI.add 和 YUI().add 有什么区别? 最佳答案 在第一种情况下,您要注册一个模块可以加载到 YUI 沙箱中,在第二种情况下,您要构建一个沙箱,然后进行注册(这是一种非常不典型的用法)。
我一直在使用 YUI 库来开发网站。 YUI 3 于 9 月发布。 我仍然不确定是否必须为迁移做好准备。 第三版比第二版有什么优势? 您最近参与过这样的迁移吗? 最佳答案 我没有参与迁移,但我为 YU
将 Yahoo JS 和 CSS 库从版本 2 升级到版本 3 的迁移路径是什么? 特别是:CSS 和字体、按钮、TabView。 如能提供有关所遇到问题的更多信息、简化问题的提示等,我们将不胜感激。
我遇到的问题是它也跟踪日志阅读器中的所有事件。这使得它很难使用。当我向上向下滚动、在阅读器中单击或移动以检查事件时,它会在各处滚动以添加新事件。有没有办法过滤它以仅包含来自某些来源的某些事件?我可能做
这个问题主要是出于学术兴趣。 我今天开始使用 YUI 3,并偶然发现了它的沙箱概念。在彻底尝试在 DOM 中找到一些对象(比如我注册的事件处理程序)后,我不得不放弃。我只是找不到任何实例对象结束于此。
YUI 似乎非常专注于为浏览器和 node.js 提供所有相同的代码。 这非常强大,因为现在我可以在两端使用相同的测试,而不必重写/重新学习任何东西。 在测试方面,谷歌是否也专注于 node.js?
我正在尝试使用 Maven 的 YUI Compressor 插件来压缩我的 CSS 和 JavaScript,但我遇到了两个问题。 我的配置正确地压缩和聚合了 JavaScript 文件,但是如果我
我正在使用Yahoo.Yui.Compressor.Build.MsBuild压缩 css 和 javascript 文件。我已经安装了Yahoo.Yui.Compressor.Build.MsBui
我正在尝试使用 YUI 3.3.0 预览版 3 charting solution因为它不再使用 Flash,而是使用浏览器 Canvas 。到目前为止,我把这些和平的代码拼凑在一起(因为我是 YUI
我正在使用 YUI,需要获取元素的真实宽度。元素的宽度可以如下确定。 宽度 + 左边框 + 右边框 + 左填充 + 右填充 + 左边距 + 右边距。 下面是我想出的。它似乎正在工作。我只是想知道这是确
我是一名优秀的程序员,十分优秀!