微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

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

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

function opsFormatter (cellvalue,options,rowObject){
    '<a title=MA href=javascript:showDialog(' + rowObject[5] + ')>MA<a>' + '&nbsp;&nbsp;';
}

而不是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',{name:'expiry',index:'expiry',width:60,stype:'select',searchoptions:{dataUrl:'expiry_select.htm'},{name:'putCall',index:'putCall',width:65,{name:'strike',index:'strike',sorttype: 'float',width:70,{name:'account',index:'account',{name:'long',index:'long',width:55,{name:'short',index:'short',{name: 'openQty',index:'openQty',width:80,align:'center',formatter:cloSEOutFormatter,{name:'LTD',index:'LTD',{index:'operations',width:105,title:false,align: 'center',formatter:opsFormatter,sortable:false}
               ],pager: '#div-pos-pager',caption: 'Positions'
});

??

解决方法

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

rowObject – is a row data represented
in the format determined from datatype
option. … If we have datatype:
json/jsonstring – the rowObject is
array,provided according to the rules
from jsonReader

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

原文地址:https://www.jb51.cc/jquery/180848.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐