- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
这是网格。
我的折扣列有一个自动完成功能,它的值来自另一个 json 变量。
这是我的 json 数组,折扣数据来自于此。
[
{"id":0.56,"label":"Adams Rite Less 50\/12","value":"Adams Rite Less 50\/12"},
{"id":0.44,"label":"ASSA Less 44","value":"ASSA Less 44"},
{"id":0.603,"label":"BARON ACCESSORIES AND STICKS Less 60.3","value":"BARON ACCESSORIES AND STICKS Less 60.3"},
{"id":0.704,"label":"BARON STD AND CUSTOM DOORS Less 70.4","value":"BARON STD AND CUSTOM DOORS Less 70.4"},
{"id":0.617,"label":"BARON STD AND CUSTOM FRAMES Less 61.7","value":"BARON STD AND CUSTOM FRAMES Less 61.7"},
{"id":0.704,"label":"BARON STD PALLET DOORS Less 70.4","value":"BARON STD PALLET DOORS Less 70.4"},
{"id":0.145,"label":"Bobrick 10\/5","value":"Bobrick 10\/5"},
{"id":0.6175,"label":"BREMNER HMD","value":"BREMNER HMD"},
{"id":0.6073,"label":"BREMNER HMF","value":"BREMNER HMF"},
{"id":0.44,"label":"Eff Eff Less 44","value":"Eff Eff Less 44"}
]
我想做的是
(1)更改折扣值后,Cost 列应根据此公式更改
new Cost = (1-0.145)*List Price Cell's value (in this case 999)
值 0.145 来自 json 的 id 列。
(2)更改折扣值后,ExtCost 列应相应更改。
New Ext Cost = Quantity * new Cost
数量是最左边的单元格。
这是我的网格相关代码。
var lastsel2;
jQuery(document).ready(function(){
var autocompleteSource;
$.getJSON("{{ asset('app_dev.php/GetDiscount') }}", function(json){
autocompleteSource = json;
});
var cont;
jQuery("#list").jqGrid({
url: "{{ asset('/app_dev.php/_thrace-datagrid/data/view_PO_details') }}",
postData: {
masterGridRowId: {{ editid }}
},
datatype: "json",
mtype: 'POST',
colNames: ['', 'Released', 'Attachments', 'Quantity', 'Received', 'Item #', 'Vendor Item #', 'List Price', 'Discount', 'Cost', 'ExtCost', 'Lead Time', 'System Key', 'PO Item Note', 'PO Required Date', 'Confirm #','Confirm Date', 'VQ #', 'Reference', 'VQ Ref', 'UOM', 'Type', 'Last Update', 'Updated By', 'FSC', 'Door #', 'Queue', 'RTE#'],
colModel: [
{
name: "POD_UISelected",
index: "o.POD_UISelected",
editable: true,
edittype: 'checkbox',
editoptions: {value: "True:False"},
formatter: "checkbox",
formatoptions: {disabled: false},
align: 'center',
jsonmap: "cell.0",
width: '70'
},
{
name: "POD_Released",
index: "o.POD_Released",
editable: true,
edittype: 'checkbox',
editoptions: {value: "Yes:No"},
formatter: "checkbox",
formatoptions: {disabled: false},
align: 'center',
jsonmap: "cell.1",
width: '70'
},
{
name: "I_LinkHasFiles",
index: "o.I_LinkHasFiles",
editable: false,
edittype: 'checkbox',
editoptions: {value: "True:False"},
formatter: "checkbox",
formatoptions: {disabled: true},
align: 'center',
jsonmap: "cell.2",
width: '70'
},
{
name: "POD_OrderQty",
index: "o.POD_OrderQty",
editable: true,
align: 'center',
jsonmap: "cell.3",
width: '100'
},
{
name: "POD_QtyReceived",
index: "o.POD_QtyReceived",
editable: true,
align: 'center',
jsonmap: "cell.4",
width: '100'
},
{name: "POD_ItemNumID #", index: "o.POD_ItemNumID", editable: false, align: 'center', jsonmap: "cell.5"},
{
name: "POD_VendorItemNum",
index: "o.POD_VendorItemNum",
editable: false,
align: 'center',
jsonmap: "cell.6"
},
{
name: "POD_VendorListPrice",
index: "o.POD_VendorListPrice",
editable: true,
align: 'center',
formatter: 'currency',
formatoptions: {prefix: '$', suffix: '', thousandsSeparator: ','},
jsonmap: "cell.7"
},
{
name: "POD_VendorDiscount",
index: "o.POD_VendorDiscount",
editable: true,
jsonmap: "cell.8",
editoptions: {
dataInit: function(elem) {
var $self = $(this), // save the reference to the grid
$elem = $(elem); // save the reference to <input>
$(elem).autocomplete({
source: autocompleteSource,
select: function (event, ui) {
var $tr = $elem.closest("tr.jqgrow"), newCost, rowid = $tr.attr("id"),
orderQty = parseFloat($tr.find("input[name=POD_OrderQty]").val()),
listPrice = parseFloat($tr.find("input[name=POD_VendorListPrice]").val());
if (ui.item) {
console.log(orderQty);
console.log(listPrice);
newCost = (1 - parseFloat(ui.item.id)) * listPrice;
$self.jqGrid("setRowData", rowid, {
POD_UnitCost: newCost,
POD_ExtCost: orderQty * newCost
});
}
},
minLength: 0,
minChars: 0,
autoFill: true,
mustMatch: true,
matchContains: false,
scrollHeight: 220
}).on('focus', function(event) {
var self = this;
$(self).autocomplete( "search", "");
});
}
}
},
{
name: "POD_UnitCost",
index: "o.POD_UnitCost",
editable: false,
align: 'center',
formatter: 'currency',
formatoptions: {prefix: '$', suffix: '', thousandsSeparator: ','},
jsonmap: "cell.9"
},
{
name: "POD_ExtCost",
index: "o.POD_ExtCost",
editable: false,
align: 'center',
formatter: 'currency',
formatoptions: {prefix: '$', suffix: '', thousandsSeparator: ','},
jsonmap: "cell.10"
},
{name: "POD_Leadtime", index: "o.POD_Leadtime", editable: false, jsonmap: "cell.11"},
{
name: "POD_Stocked",
index: "o.POD_Stocked",
editable: false,
edittype: 'checkbox',
editoptions: {value: "True:False"},
formatter: "checkbox",
formatoptions: {disabled: true},
align: 'center',
jsonmap: "cell.12"
},
{name: "POD_Note", index: "o.POD_Note", editable: true, jsonmap: "cell.13"},
{
name: "POD_ReqDate",
index: "o.POD_ReqDate",
editable: true,
jsonmap: "cell.14.date",
editoptions:{size:20,
dataInit:function(el){
$(el).datepicker({dateFormat:'yy-mm-dd'});
},
defaultValue: function(){
var currentTime = new Date();
var month = parseInt(currentTime.getMonth() + 1);
month = month <= 9 ? "0"+month : month;
var day = currentTime.getDate();
day = day <= 9 ? "0"+day : day;
var year = currentTime.getFullYear();
return year+"-"+month + "-"+day;
}
}
},
{name: "POD_ConfrmNum", index: "o.POD_ConfrmNum", editable: true, jsonmap: "cell.15"},
{
name: "POD_PromDate",
index: "o.POD_PromDate",
editable: true,
jsonmap: "cell.16.date",
editoptions:{size:20,
dataInit:function(el){
$(el).datepicker({dateFormat:'yy-mm-dd'});
},
defaultValue: function(){
var currentTime = new Date();
var month = parseInt(currentTime.getMonth() + 1);
month = month <= 9 ? "0"+month : month;
var day = currentTime.getDate();
day = day <= 9 ? "0"+day : day;
var year = currentTime.getFullYear();
return year+"-"+month + "-"+day;
}
}
},
{name: "VQ_PK", index: "o.VQ_PK", editable: false, jsonmap: "cell.17"},
{name: "pod_reftext", index: "o.pod_reftext", editable: false, jsonmap: "cell.18"},
{name: "VQ_VRef", index: "o.VQ_VRef", editable: false, jsonmap: "cell.19"},
{name: "POD_UOM", index: "o.POD_UOM", editable: false, jsonmap: "cell.20"},
{name: "POD_ItemType", index: "o.POD_ItemType", editable: false, jsonmap: "cell.21"},
{name: "POD_DateUpdated", index: "o.POD_DateUpdated", editable: false, jsonmap: "cell.22.date"},
{name: "POD_UpdatedSysUser", index: "o.POD_UpdatedSysUser", editable: false, jsonmap: "cell.23"},
{name: "I_FSC", index: "o.I_FSC", editable: false, jsonmap: "cell.24"},
{name: "PjD_NumID", index: "o.PjD_NumID", editable: false, jsonmap: "cell.25"},
{name: "POD_QueueSourceText", index: "o.POD_QueueSourceText", editable: false, jsonmap: "cell.26"},
{name: "RTP_PK_E", index: "o.RTP_PK_E", editable: false, jsonmap: "cell.27"}
],
beforeSelectRow: function (rowid, e) {
var $target = $(e.target), $td = $target.closest("td"),
iCol = $.jgrid.getCellIndex($td[0]),
colModel = $(this).jqGrid("getGridParam", "colModel");
if (iCol >= 0 && $target.is(":checkbox")) {
if(colModel[iCol].name == "POD_UISelected")
{
$('#list').setSelection(rowid, true);
$("#list").jqGrid('saveRow', rowid, { //same rowid value used in 'addRowData' method above
succesfunc: function (response) {
$('#list').trigger( 'reloadGrid' );
return true;
}
})
}
}
return true;
},
onSelectRow: function(id){
if(id && id!==lastsel2){
jQuery('#list').jqGrid('restoreRow',lastsel2);
jQuery('#list').jqGrid('editRow',id,true);
lastsel2=id;
}
},
jsonReader: {repeatitems: false},
height: 400,
rowNum: 50,
rowTotal: 1000000,
autowidth: true,
gridview: true,
autoencode: false,
pager: '#pager',
shrinkToFit: true,
sortable: true,
sortname:"o.POD_ReqDate",
sortorder: "desc",
viewrecords: true,
//multiselect: true,
loadonce:false,
rowList: [50, 100, 500, 1000],
editurl: "{{ asset('/app_dev.php/_thrace-datagrid/row-action/view_PO_details') }}"
});
jQuery("#list").jqGrid('navGrid',"#pager",{ del:false, add:false, edit:false},
{editData: {PO_PK: {{ editid }}}},
{editData: {PO_PK: {{ editid }}}},
{editData: {PO_PK: {{ editid }}}},
{multipleSearch:true}
);
jQuery("#list").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : true});
jQuery('#list').jqGrid('gridResize');
$("#productEdit_V_PK").prop("disabled", true);
});
最佳答案
您没有提供工作演示,但我希望我仍然正确理解您的意思。
我认为您想更改不可编辑列的值 POD_UnitCost
和 POD_ExtCost
在可编辑的 jQuery UI 自动完成控件中选择值 POD_VendorDiscount
.另一个可编辑列的值 POD_OrderQty
和 POD_VendorListPrice
计算时会用到。当前代码来自 select
自动完成回调
var rowData = $('#list').jqGrid('getRowData', rowid);
cont = rowData.POD_VendorListPrice;
console.log(cont);
rowData.POD_ExtCost = (1-ui.item.id)*cont;
不正确。第一个问题是 getRowData
的用法访问当前处于<strong>内联编辑 模式的列。这是不对的。 getRowData
将从单元格中获取 HTML 片段而不是 value
相应的<input>
元素。第二个错误:你刚刚设置了POD_ExtCost
的 rowData
没有任何额外操作的对象。它不会更改 POD_ExtCost
中的值柱子。你应该做什么:你可以使用 getRowData
和 setRowData
要获取/设置 不编辑列 的值,您必须获取 <input>
编辑元素的元素并得到它的value
获取当前编辑值。
我无法测试下面的代码,但正确的方法可能是例如下面的
dataInit: function(elem) {
var $self = $(this), // save the reference to the grid
$elem = $(elem); // save the reference to <input>
$elem.autocomplete({
source: autocompleteSource,
select: function (event, ui) {
var $tr = $elem.closest("tr.jqgrow"), newCost, rowid = $tr.attr("id"),
orderQty = parseFloat($tr.find("input[name=POD_OrderQty]").val()),
listPrice = parseFloat($tr.find("input[name=POD_VendorListPrice]").val());
if (ui.item) {
console.log(orderQty);
console.log(listPrice);
newCost = (1 - parseFloat(ui.item.id)) * listPrice;
$self.jqGrid("setRowData", rowid, {
POD_UnitCost: newCost,
POD_ExtCost: orderQty * newCost
});
}
},
minLength: 0,
minChars: 0,
autoFill: true,
mustMatch: true,
matchContains: false,
scrollHeight: 220
}).on("focus", function(event) {
$(this).autocomplete("search", "");
});
}
我应该指出,上面的代码仅适用于内联编辑。
关于javascript - jqgrid 在更改另一个单元格时更改可编辑单元格的值(相关列),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30645088/
我试图要求 test/unit 的新版本(即不是与 ruby 捆绑的版本) .根据 instructions我用 gem i test-unit 安装它.但是现在当我需要 test/unit我似乎
简短版本是: 我有一个 systemd 单元,我想在调用时检查脚本的返回代码: systemctl status service.service 长版本:我有一个 lsb init 脚本正是这样做的,
我正在使用反射动态创建一个类的实例,这工作正常,除非尝试通过单元测试执行此操作 - 我使用的是 MS 测试框架。 我收到熟悉的错误:“无法加载文件或程序集‘Assy’或其依赖项之一。系统找不到指定的文
我想知道测试网站“界面功能”的最佳实践是什么。 我对哪些方法可用于测试界面和动态生成的内容感兴趣。特别是,我很难弄清楚是否可以为需要用户交互的操作创建自动化测试,或者这是否只是浪费时间,我应该让一些
我有一个简单的 Python 服务,其中有一个无限执行某些操作的循环。在各种信号上,sys.exit(0) 被调用,这导致 SystemExit 被引发,然后如果可以的话应该进行一些清理。 在测试中,
我正在使用 OpenCV 2.4.2 这是 OpenCV 文档中的引文 C++: void HoughLinesP(InputArray image, OutputArray lines, doubl
忙于 C# 中的自动化测试用例,我们需要在每次测试后恢复数据库快照。问题是,当运行多个测试时它会失败,因为“其他用户正在使用数据库时无法更改数据库状态。” 我们使用 SqlConnection.Cle
我阅读了 C# 规范并用谷歌搜索了它,但一无所获。 我 99% 肯定 C# 中没有像单元命名空间指令这样的功能,但问题是:为什么?是否有惯用或技术原因? 这很方便,尤其是当我们的大部分文件都由单个命名
我目前正在尝试向我的应用程序(一个非常老的项目......评论说 iOS 2.0)添加单元测试(精确的应用程序测试)并且总是偶然发现 undefined symbols for architectur
我正在使用Delphi 7,并且有一个新单元要在我的项目中使用。我已经编译了新的。当我尝试通过将其添加到uses子句在项目中使用此单元时,出现错误,提示未找到.dcu文件。我还尝试将文件的完整路径放在
场景:我需要编写一个复杂的nHibernate查询,该查询将返回预计的DTO,但是我想使用TDD方法。该方法如下所示: public PrintDTO GetUsersForPrinting(int
您可以通过运行以下命令在事件 html 设置中显示 Jupyter 笔记本: $ jupyter nbconvert untitled.ipynb --to slides --post serve 有
如何在一个网站上拥有多个 AdSense 单元? Google 提供的唯一代码是按单位计算的。 (adsbygoogle = window.adsbygoogle || []).push({})
我刚刚开始为大量代码编写测试。有很多类依赖于文件系统,即读取 CSV 文件、读/写配置文件等。 当前测试文件存储在项目(这是一个 Maven2 项目)的 test 目录中,但由于多种原因该目录并不总是
我对 TDD 还很陌生,在单元测试方面也不是很老练,所以才有这个问题。我有这个用 PHP 编写的遗留函数 function foo(){ x = bar(); y = baz();
我创建了一个程序,在 Swing 窗口的一侧显示结果过滤选项,但默认情况下它们水平相邻显示,这浪费了我在 BorderLayout 的西侧分配的空间。我可以在构造函数或添加语句中传递任何内容来将它们堆
标题不好的借口:如果有人能更好地描述它,请做。 我有一个 WeakList类,它“基本上”是一个 List> (虽然不是字面意义上的派生自列表,但它应该对用户完全透明)。 现在的基本思想是“如果引用的
我正在尝试在 UITableView 上添加两个原型(prototype)单元。但是,我不知道如何验证是否能够为每个原型(prototype)“返回”正确的单元格。你们能帮我一下吗? func ta
我正在使用 CloudKit 作为数据库创建一个简单的待办事项列表应用程序。目前我可以添加和删除对象,但对编辑对象感到困惑。 编辑项目 Controller protocol EditItemCont
我正在针对以下任务训练 RNN:给定一个包含 30 个单词的序列,然后将该序列分类为二进制类。 在我的网络中拥有超过 30 个单元(LSTM、GRU 或普通 RNN)有好处吗?我在网上看到过很多例子,
我是一名优秀的程序员,十分优秀!