gpt4 book ai didi

javascript - YUI数据表错误

转载 作者:行者123 更新时间:2023-12-02 20:41:21 25 4
gpt4 key购买 nike

我正在尝试组合一个使用 YUI 的 DataTable 组件的应用程序,但收到“数据错误”消息。数据源配置为从 ASP.NET Web 方法获取记录。记录成功返回到客户端(我用IE的调试器检查过)。我的代码如下所示:

YAHOO.example.Basic = function() {
var dsWS_Restaurants = new YAHOO.util.DataSource("/DemoWebSite/RestaurantsWebService.asmx/GetList", { connMethodPost: true });

dsWS_Restaurants.connMgr = YAHOO.util.Connect;
dsWS_Restaurants.connMgr.initHeader('Content-Type', 'application/json; charset=utf-8', true);
dsWS_Restaurants.responseType = YAHOO.util.DataSource.TYPE_JSON;

dsWS_Restaurants.doBeforeParseData =
function(oRequest, oFullResponse, oCallback) {
// checked here if oFullResponse contains the desired results and it does.
}

dsWS_Restaurants.responseSchema =
{
resultsList: 'd.records',
fields: ["id", "name"]
};

var dsWS_Restaurants_ColumnDefs = [
{ key: "id", sortable: true, resizeable: true },
{ key: "name", sortable: true, resizeable: true }
];

var dsWS_Restaurants_DataTable =
new YAHOO.widget.DataTable("basic4", dsWS_Restaurants_ColumnDefs, dsWS_Restaurants, { caption: "dsWS_Restaurants" });

return {
oDS: dsWS_Restaurants,
oDT: dsWS_Restaurants_DataTable
};
} ();

...

Web 方法如下所示:

public Object GetList() {
var restaurants =
new []{
new
{
id="1",
name="Popeyes spinach"
},
new
{
id="2",
name="Big pappas cottage"
}
};

return restaurants.Select (x => new { id = x.id, name = x.name });

}

欢迎并感谢任何帮助。提前致谢。

最佳答案

我相信可重写的 doBeforeParseData 方法应该返回 oFullResponse 对象...

        dsWS_Restaurants.doBeforeParseData =
function(oRequest, oFullResponse, oCallback) {
// checked here if oFullResponse contains the desired results and it does.
return oFullResponse;
}

..但可能不仅仅如此。

关于javascript - YUI数据表错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2327035/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com