好的 - 不确定是否有人对此有答案。我假设还有其他人也想要这些信息......
我正在使用pqgrid,并希望轻松地将从cfc发送的json转换为网格的“数据”。我没有运气就尝试过很多东西。它总是抛出一个关于解析json的错误。我的最后一次尝试如下:
CFC:
<cffunction name="getResources" access="remote"
returntype="query" HINT="Get All Resources" returnFormat="JSON">
<cfquery name="get_resources" datasource="#Session.ODBC#">
SELECT *
FROM Resources
ORDER BY resourcename
</cfquery>
<CFRETURN get_resources>
</cffunction>
JQUERY:
dataModel: {
dataType: "JSON",
location: "remote",
recIndx: "resourceid",
url: "/cfc/Exercise.cfc?method=getResources&queryFormat=column",
getData: function (response) {
return { data: response.DATA };
}
},
编辑:
我相信返回的JSON是正确的 - 假设pqgrid还有其他方式:
{
"ROWCOUNT":10
, "COLUMNS":[ "RESOURCEID"
, "FK_EXERCISEID"
, "FK_SIMULATORGROUPID_OWNER"
, "FK_SIMULATORID_OWNER"
]
, "DATA":{
"RESOURCEID":[624,594,593,596,628,513,514,515,516,517]
, "FK_EXERCISEID":[6,6,6,6,6,6,6,6,6,6]
, "FK_SIMULATORGROUPID_OWNER":[31,25,25,25,25,26,26,26,26,26]
, "FK_SIMULATORID_OWNER":[0,0,0,0,0,0,0,0,0,0]
}
}