DataTable表构建后如何修改

发布于 2024-10-17 00:48:04 字数 225 浏览 2 评论 0原文

我想在 ajax 查询完成时修改 YUI DataTable。例如,我有 4 个 ajax 查询,查询需要 1 秒到 10 秒才能完成的事情。我想在1s查询完成时开始构建表,并在每次ajax查询完成时再次修改表。一般来说,有推荐的方法吗?

特别是,我想更改列的格式以显示处理行时发生的任何潜在错误。但是,错误处理速度很慢,因此先显示数据然后再添加错误会很有帮助。

非常感谢您的帮助!

贾森

I would like to modify a YUI DataTable as ajax queries get completed. So for example, i have 4 ajax queries querying for things which takes anywhere from 1s to 10s to complete. I would like to start constructing the table when the 1s query finish, and modify the table again every time a ajax query finishes. Is there a recommended way of doing this in general?

In particular, i would like to change how the column is formatted to display any potential errors that occurs while processing a row. However, the error processes slowly, so it would be beneficial to display the data first and then add on the errors later.

Thanks a lot for any help!

Jason

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

箜明 2024-10-24 00:48:04

我假设您的多个请求正在聚合列数据。我还假设该表是静态的(不是服务器端分页或排序)。

  1. 设置 DataTable 的列定义以包括来自所有源的所有列。
  2. 创建一个指向最快查询的服务 url 的数据源。
  3. 使用该数据源实例化数据表。
  4. 要么为其他服务创建更多数据源,要么为每个其他服务调用 YAHOO.util.Connect.asyncRequest(...) 每个
  5. 服务请求的回调应该按照以下方式执行一些操作:(

前面的伪代码)

function callback(data) {
    var recordset = myDataTable.getRecordSet(),
        records = recordset.getRecords(),
        i, len, rec;

    for (i = 0, len = records.length; i < len; ++i) {
        rec = records[i].getData(); // will return an object literal with data info
        /* match the record object to the new data and update the record object */
    }

    recordset.setRecords(records);
    myDataTable.render();
}

因此每个附加服务将在记录级别添加数据,然后更新完整的表 UI。

华泰

I'm presuming your multiple requests are aggregating column data. I'm also assuming the table is static (not server side paging or sorting).

  1. Set up the column definition for the DataTable to include all the columns from all sources.
  2. Create a DataSource pointing to the service url of the fastest query.
  3. Instantiate the DataTable with that DataSource.
  4. Either create more DataSources for the other services, or call YAHOO.util.Connect.asyncRequest(...) for each other service
  5. The callbacks for each of these service requests should do something along these lines:

(pseudo-code ahead)

function callback(data) {
    var recordset = myDataTable.getRecordSet(),
        records = recordset.getRecords(),
        i, len, rec;

    for (i = 0, len = records.length; i < len; ++i) {
        rec = records[i].getData(); // will return an object literal with data info
        /* match the record object to the new data and update the record object */
    }

    recordset.setRecords(records);
    myDataTable.render();
}

So each additional service will add data at the Record level, then the full table UI will be updated.

HTH

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文