YUI数据表未使用服务器中的数据刷新。
我尝试了以下两个选项:
选项1:
myDataTable.getDataSource().liveData = 'http://localhost:8080/YUIDemo/getRMADetails';
myDataTable.getDataSource().sendRequest(null, {
success: function (oRequest, oResponse, oPayload) { YAHOO.log('got...'+oResponse.results.length);
myDataTable.onDataReturnInitializeTable;},
failure: function (){ YAHOO.log("table refresh failed");},
scope: myDataTable}, myDataTable);
选项2:
var myDataSource = new YAHOO.util.XHRDataSource("http://localhost:8080/YUIDemo/getRMADetails");
myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
myDataSource.responseSchema = {
fields : [ "rma", "rmaLineNumber", "status", "statusDesc",
"completeDate", "completeTime" ]
};
myColumnDefs = [ {key : "rma", label: "RMA", sortable : true, resizeable : true},
{key : "rmaLineNumber", label: "RMA Line Number", sortable : true, resizeable : true},
{key : "status", label: "Status", sortable : true, resizeable : true},
{key : "statusDesc", label: "Status Desc", sortable : true, resizeable : true},
{key : "completeDate", label: "Complete Date", sortable : true, resizeable : true},
{key : "completeTime", label: "Complete Time", sortable : true, resizeable : true} ];
myDataTable = new YAHOO.widget.DataTable("basic", myColumnDefs, myDataSource,{caption:"Results"});
myDataTable.getDataSource().sendRequest(null,
{success: function (oRequest,oResponse,oPayload){YAHOO.log('got...'+oResponse.results.length);myDataTable.onDataReturnInitializeTable;},
failure: function (){YAHOO.log("table refresh failed");},
scope: myDataTable},myDataTable);
答案 0 :(得分:0)
你不应该给它http://localhost:8080/YUIDemo/getRMADetails
而只是给它getRMADetails依赖的相对路径以及你的javascript文件在哪里。
还要确保从getRMADetails返回的数据具有与数据源的responseSchema中的字段匹配的键。