如何使用按钮刷新YUI dataTable? [英] How can I refresh a YUI dataTable with a button?

查看:164
本文介绍了如何使用按钮刷新YUI dataTable?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在测试脚本:


http://developer.yahoo.com/yui/examples/datatable/dt_xhrjson.html

我想添加一个按钮来刷新(重置)数据。
我将重置所有修改的数据并重新加载第一个数据。
我添加这个代码,所以在选择(刷新)后,我没有数据:

I would like to add a button to refresh(reset) the data. I would reset all modified data and reload first data. I add this code, so after select (refresh), I have no data:

YAHOO.util.Event.onContentReady("splitbuttonsfromjavascript", function () {

var onMenuItemSelect = function () {

        myDataTable.initializeTable();

        myDataTable.render();

        };

        var aSplitButton5Menu = [

            { text: "Refresh", value: 1, onclick: { fn: onMenuItemSelect } }

        ];

        var oSplitButton5 = new YAHOO.widget.Button({ type: "split",  label: "Refresh table", name: "splitbutton", menu: aSplitButton5Menu, container: this });

    });

我需要在我的onMenuItemSelect中使用以刷新mydataTable?

What I need to use in my onMenuItemSelect to refresh mydataTable?

我进行了一些修改,以修改示例中的city和rating:
http://developer.yahoo.com/yui/examples/datatable/dt_xhrjson.html

I made some changes to modify the "city" and "rating" in the sample : http://developer.yahoo.com/yui/examples/datatable/dt_xhrjson.html

现在,我希望使用按钮重置MyTable(并重新加载默认数据集)。
当我使用我的代码,按钮后,我清除所有和默认数据没有重新加载(我有:没有找到记录按钮后)。

Now, I wish resetting MyTable with a button (and reload default dataset). When I use my code, after button click, I clear all and default data are not reloaded (I have : "No records found." after button click).

我如何重新加载默认数据?

How I can reload default data ?

推荐答案

我认为Gourneau的答案是最好的,但它缺少一个很好的触摸。为了获得显示的加载...信息,您需要调用showTableMessage函数。

I think Gourneau's answer is the best, but it is missing one nice touch. In order to get the 'Loading...' message to display, you need to make a call to the showTableMessage function.

myDataTable.showTableMessage("Loading...");
myDataTable.getDataSource().sendRequest('', { success: myDataTable.onDataReturnInitializeTable, scope: myDataTable });

当请求完成时,onDataReturnInitializeTable函数将自动清除表消息。

When the request is finished, the onDataReturnInitializeTable function will automatically clear the table message.

我也发布在我的博客上。

这篇关于如何使用按钮刷新YUI dataTable?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆