我正在使用我需要用 JsonRest 填充的道场网格。
这是代码:
require
(
[ 'dojo/_base/lang', 'dojox/grid/DataGrid', 'dojo/data/ObjectStore', 'dojo/store/JsonRest', 'dojo/dom', 'dojo/domReady!' ],
function ( lang, DataGrid, ObjectStore, JsonRest, dom )
{
jsonr = new JsonRest
(
{ target: 'carrierSlideListStrategiesByGroupOrCarrierAction.do?output=<%=Constants.OUTPUT_JSON%>' }
);
var layout =
[
[
{ 'name': 'strategyname', 'field': 'strategyid', 'width': '23%', 'cellStyles': 'white-space: nowrap;', 'headerStyles': 'white-space: normal; word-wrap: normal; text-align: center;' }
]
];
grid00 = new DataGrid
(
{
store: store00 = new ObjectStore ( { objectStore: jsonr } ),
structure: layout,
rowSelector: '20px'
}
);
grid00.placeAt ( 'grid00' );
grid00.startup ();
dojo.connect
(
grid00,
"_onFetchComplete",
function ()
{
$ ( '#msg_home' ).empty ();
$ ( '#msg_home' ).html ( '<table><tr><td><bean:message key="bodycarrierslidebygrouporcarrier.query.businessnumbers.done00"/>' + '<b>' + grid00.rowCount + '</b>' + '<bean:message key="bodycarrierslidebygrouporcarrier.query.done01"/></td></tr></table>' );
}
);
}
);
我得到的数据收集如下:
[{"strategyid":"1","strategyname":"AR","strategycompliantflag":"GROUP_STRATEGY_NA"},
{"strategyid":"0","strategyname":"Facilities","strategycompliantflag":"GROUP_STRATEGY_NA"},
{"strategyid":"1","strategyname":"Panel","strategycompliantflag":"GROUP_STRATEGY_NA"},
{"strategyid":"0","strategyname":"Agreem.","strategycompliantflag":"GROUP_STRATEGY_NA"}
- ETC
我似乎不知道如何实现的目标是在网格的标题中放入字段 strategyname 的值,并在行中放入字段 strategyid 的值,而不是我只在标题中输入一个像这样的列:
-------------
strategyname
-------------
1
0
1
我想拥有
------ ------------- ------- ----
AR Facilities Panel Agreem
------ ------------ -------- --------
1 0 1 0
为此,我认为我可以通过数据收集循环查询 JsonRest,以形成我需要的结构并将其传递给网格。
有人可以帮我吗?