我們有一個數據類型爲json的網格。訪問jqGrid自定義格式化程序中的行數據
我們有以下的自定義格式:
function opsFormatter (cellvalue, options, rowObject){
'<a title=MA href=javascript:showDialog(' + rowObject[5] + ')>MA<a>' + ' ';
}
取而代之的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 [5]'工作,但'rowObject [「account」]'和'rowObject.account'不起作用。我想要的是能夠使用最後兩個變種.. – 2010-10-27 22:40:50
是因爲我們使用'loadOnce:true'?也許這會導致一個問題,因爲這個設置會導致grid數據類型爲'local' ..文檔提到了一些關於對象表示法的東西,只能用於JSON數據類型。 – 2010-10-27 22:41:34
@Marcus:在我的示例中,我可以使用像rowObject這樣的表示法。 account'。你應該發佈測試JSON數據和更多完整的'jqGrid'代碼,這些代碼可以用來重現你的問題。 – Oleg 2010-10-27 23:03:19