[英]I want to Edit the text in Cell of a JQgrid, without editing the existing Text present while editing
該單元格中的示例EX應該是固定的,並且想要在該單元格中添加EX / E2或EX / E5這樣的人...誰能告訴我在此事件中編寫的代碼或val中的 editoptions我正在獲得EX
afterEditCell: function (id, name, val, iRow, iCol) {
$("#" + iRow + "_" + name).bind('blur', function (e) {
$('#grid').saveCell(iRow, iCol);
});
}
editoptions: {
dataEvents: [
{
type: 'keypress',
fn: function (event, rowid) {
if ((event.which != 37 && (event.which != 39)) && ((this.selectionStart < readOnlyLength) || ((this.selectionStart == readOnlyLength) && (event.which == 8))))
{
return false;
}
$(this).val($(this).val().replace(/[^0-9\.]/g, ''));
if ((e.which != 46 || $(this).val().indexOf('.') != -1) && (e.which < 48 || event.which > 57)) {
e.preventDefault();
}
}
}]
}
如果您使用Guriddo jqGrid JS ,則可以使用自定義元素定義並借助custom_element和custom_value來執行所需的操作。 您可以在此處閱讀礦石(請參閱自定義元素類型)。
波紋管是您的野外字段的代碼
colModel :[
...
{ name:'wed1',
edittype: 'custom',
editoptions : {
custom_element : function (value, options) {
var val = value.split("/"), rval;
var el = "<label for='note'>"+val[0]+"/</label>";
if(val[1] !== undefined) {
val.shift();
rval = val.join(",");
} else {
rval = '';
}
el += "<input type='text' value='"+rval+"'/>";
return $(el);
},
custom_value : function (elem, operation, value) {
if(operation === 'get') {
return $(elem[0]).text() + $(elem[1]).val();
} else if(operation === 'set') {
$('input',elem).val(value);
}
}
}
}
這只是想法。 在實際示例中,您將需要分析輸入字符串是否包含或/,但是無論如何您都可以使用另一種方法來分隔單元格的原始值
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.