访问jqGrid自定义格式化程序中的行数据

我们有一个数据类型为json的网格。

我们有以下自定义格式化程序:

function opsFormatter (cellvalue, options, rowObject){ 'MA' + '  '; } 

而不是rowObject[5]是否有任何对象表示法,我们可以指定实际的列名称(“帐户”)? 即: rowObject.account

这是网格定义:

 $("#grid-pos").jqGrid({ colNames:['Product', 'Type','Expiry', 'Put Call', 'Strike', 'Account','Long','Short', 'Open Qty', 'LTD', 'Operations'], colModel :[ {name:'product', index:'product', width:75, sortable:false}, {name:'type', index:'type', width:50, align:'right', sortable:false}, {name:'expiry', index:'expiry', width:60, align:'right',stype:'select', searchoptions:{dataUrl:'expiry_select.htm'}, sortable:false}, {name:'putCall', index:'putCall', width:65, sortable:false}, {name:'strike', index:'strike', sorttype: 'float', width:70, sortable:false}, {name:'account', index:'account', width:70, sortable:false}, {name:'long', index:'long', width:55, align:'right', sortable:false}, {name:'short', index:'short', width:55, align:'right', sortable:false}, {name: 'openQty', index:'openQty', width:80, align:'center', formatter:closeoutFormatter, sortable:false}, {name:'LTD', index:'LTD', width:65, align:'right', sortable:false}, {index:'operations', width:105, title:false, align: 'center', formatter:opsFormatter, sortable:false} ], pager: '#div-pos-pager', caption: 'Positions' }); 

??

对我来说似乎绝对正确的行为。 参数rowObject的值是具有与colModel的’name’属性中定义的名称相同的属性的对象。 物业account就是那里的一个。 我认为误解来自自定义格式化程序的以下部分文档:

rowObject – 是以datatype选项确定的格式表示的行数据。 …如果我们有数据类型:json / jsonstring – rowObject是数组,根据jsonReader的规则提供

可能会误解。 在JavaScript中, rowObject.account可以用作rowObject["account"] ,但是不能使用rowObject[5]来访问rowObjectaccount属性。 在文档中只是不清楚书面句子。 如果您是母语为英语的人,您可以重新制定文本,这样就不会产生误解。 文档是wiki,任何人都可以更改任何文本。