添加一个jqgrid列,它是另外两个列的结果

编程入门 行业动态 更新时间:2024-10-11 21:30:41
本文介绍了添加一个jqgrid列,它是另外两个列的结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想对jqGrid表的列值求和.我的jqGrid "SL", "Item", "Quantity", "Rate","Amount"中有四列,其中Amount是Quantity*Rate的结果,此乘法不是查询检索到的数据,而是在内部完成的javascript代码.现在我想对金额列求和.总和正确显示.我已经用警报检查了它,但是当我尝试在页脚行$grid.jqGrid('footerData', 'set', { 'amountcalculate': parseFloat(colSum)});上设置它时却显示了NAN.为什么不是我之前使用过页脚行并进行了求和.它工作得非常好.当我尝试添加由另外两列组成的列值时,它不起作用. 这是我的代码

I want to sum the column values of a jqGrid table.I have four columns in my jqGrid"SL", "Item", "Quantity", "Rate","Amount",where Amount is the result of Quantity*Rate this multiplication is not a query retrieved data.It is done inside the javascript code.Now I want to sum the amount column.Summation is showing correctly.I've checked it with an alert but when I tried to set it on footer row$grid.jqGrid('footerData', 'set', { 'amountcalculate': parseFloat(colSum)}); it is showing NAN.why is it not working.I have used footer row earlier and did summation.It worked perfectly.When I tried to add the column value which is a result of two other columns then it does not work. Here is my code

subGrid : true, subGridRowExpanded: function (subgridId, rowid) { var subgridTableId = subgridId + "_t"; $("#" + subgridId).html("<table id='" + subgridTableId + "'></table>"); $("#" + subgridTableId).jqGrid({ datatype: "json", url: "/bbbb/regfgfgfisterFgshGood /listReceivableOrderDetails?id=" + rowid, colNames: ["SL", "Item", "Quantity", "Rate","Amount"], colModel: [ {name: "sl", width: 40, align: 'center'}, {name: "item", width: 230, align: 'left'}, {name: "quantity", width: 100, align: 'center'}, {name: "amount", width: 100, align: 'right'}, { name: "amountcalculate", width: 60, formatter: function (cellvalue, options, rowObject) { var rq = parseFloat(rowObject[2] ); var up = parseFloat(rowObject[3] ); return parseFloat(rq * up).toFixed(2); } } ], height: "100%", rowNum: -1, sortname: "name", footerrow : true, idPrefix: "s_" + rowid + "_" }); debugger var $grid = $("#" + subgridTableId); var colSum = $grid.jqGrid('getCol', 'amountcalculate', false, 'sum'); alert(colSum); $grid.jqGrid('footerData', 'set', { 'amountcalculate': parseFloat(colSum)}); },

推荐答案

请在所有问题中包括有关您使用(可以使用)的jqGrid版本和jqGrid分支的信息 (免费jqGrid ,商业 Guriddo jqGrid JS 或版本< = 4.7的旧jqGrid).解决方案可能取决于信息.

Please include in all your questions the information about the version of jqGrid, which you use (can use) and the fork of jqGrid (free jqGrid, commercial Guriddo jqGrid JS or an old jqGrid in version <=4.7). The solution can have depend on the information.

我认为问题的根源是使用自定义格式化程序而没有来指定相应的取消格式化程序功能.请参阅文档.

I suppose that the origin of your problem is the usage of custom formatter without specifying the corresponding unformatter function. See the documentation.

通常,最好将自定义格式化程序替换为jsonmap函数,该函数将基于其他两个属性的值返回计算出的值.例如,它允许将jsonmap函数与另一个格式化程序(例如,与formatter: "currency",formatter: "integer"等)组合.

In general, it's better to replace custom formatter to jsonmap function, which return the calculated value based on the value of tow other properties. It allows for example to combine the jsonmap function with another formatter, for example with formatter: "currency", formatter: "integer" and so on.

更多推荐

添加一个jqgrid列,它是另外两个列的结果

本文发布于:2023-11-22 04:46:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1616029.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:它是   两个   jqgrid

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!