作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在我的情况下,我需要允许用户编辑网格中的各种单元格,然后稍后将整个网格保存到服务器。我已经通过内联编辑和保存到“clientArray”几乎解决了这个问题。但是,我正在尝试使用 editRules 并且遇到了一些问题。
如果我使一列可编辑,并使用编辑规则要求它是一个数字
{ name: 'Value', index: 'Value', width: 50, sortable: true,edittype: 'text',
editable: true, editoptions: { maxlength: 10 },
editrules:{number: true},
formatter:currencyFmatter, unformat:unformatCurrency },
onSelectRow
中控制编辑和保存事件:
onSelectRow: function(id){
if(id && id!==lastSel){
jQuery("#Groups").saveRow(lastSel,true,'clientArray');
jQuery("#Groups").editRow(id,true);
}
lastSel=id
},
if(id && id!==lastSel){
//dont save if first click
if (lastSel != -1) {
//get val of Value to check
var chkval = jQuery("#"+lastSel+"_Value").val() ;
// verify it is a number
if (isNaN(chkval)) {//If not a number
//Send Validation message here
//Restore saved row
jQuery("#Grid").restoreRow(lastSel);
//Return to failed save row
jQuery("#Grid ").setSelection(lastSel,false);
//reopen for editing
jQuery("#Grid ").editRow(lastSel,true);
//Note - dont reset lastSel as you want to stay here }
else {
// If number is good, proceed to save and edit next
jQuery("#Grid ").jqGrid('saveRow',lastSel, checksave, 'clientArray', {}, null, myerrorfunc);
jQuery("#Grid ").editRow(id,true);
lastSel=id;
};
isDirty = true;
};
else {
//first click - open row for editing
alert("new Edit")
jQuery("#Grid ").editRow(id,true);
lastSel=id;}
}
最佳答案
为了解决这个问题,我使用了插件 jquery.limitkeypress.min.js。
onSelectRow: function(id){
if(id && id!==lastsel){
jQuery('#treegrid').jqGrid('restoreRow',lastsel);
jQuery('#treegrid').jqGrid('editRow',id, true);
$("input[name=Presupuesto]").limitkeypress({ rexp: /^[+]?\d*\.?\d*$/ });
lastsel=id;
}
}
关于jqGrid - 内联编辑和陷印编辑规则,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2359011/
使用下面的代码,我能够得到正确的答案,但是它重复了 两次 . 例如,我只想要 [1.2038, 1.206] 的结果,但下面的代码打印 [1.2038, 1.206, 1.2038, 1.206] .
我正在尝试显示我从 https://www.findomestic.it/ 中抓取 的结果, 我收到一个错误 我的代码在这里: from selenium.webdriver.common.by im
假设我有以下代码: double median = med(10.0, 12.0, 3.0); //method returns middle number as double 现在,我想写一条消息说
我是一名优秀的程序员,十分优秀!