我在jqgrid中有一个定义为数字的列。用户被迫输入6.5之类的数字,逗号分隔符为点。 这个网格也被德语人士使用,他们习惯使用逗号作为分隔符插入像这样的数字6,5。
当不允许他们插入6,5而不是6.5:D
时,这个人会感到不安为了让他们(以及最后)我的生活更方便,我正在寻找一种方法将6,5自动转换为6.5。这应该在客户端完成,因为我想依赖于jqgrid num checking。
因此我应该在jqgrid检查之前检查(并且可能转换)该数字。 这可能吗?
- 编辑 -
除第一个函数外,这些函数都不会被调用。 知道为什么会这样吗?
afterInsertRow:function (rowid, aData){
alert('fire');
},
beforeSaveCell : function(rowid,celname,value,iRow,iCol){
alert('no fire');
return "new value";
},
beforeSubmitCell : function(rowid,celname,value,iRow,iCol){
alert('no fire2');
return "new value";
},
beforeEditCell : function(rowid,celname,value,iRow,iCol){
alert('no fire3');
return "new value";
},
- EDIT2 -
这是我用于内联编辑的代码。
onSelectRow: function(row_id){
if(row_id != null) {
var date_str = jQuery('#grid').getCell(row_id, 'date_str');
//var sum = jQuery('#grid').getCell(row_id, 'sum');
var description = jQuery('#grid').getCell(row_id, 'description');
if(date_str != "Total"){
if(row_id !== last_selected_row) {
if(row_id == -99){
//thats the first click of the user after initial load of the grid
jQuery('#grid').jqGrid('saveRow',row_id)
.editRow(row_id, true,true,reload);
last_selected_row = row_id;
}
else{
//after user jumps from one cell to another using the mouse
jQuery('#grid').jqGrid('saveRow',last_selected_row,reload);
jQuery('#grid').jqGrid('restoreRow',last_selected_row);
last_selected_row = row_id;
}
} else {
jQuery('#grid').jqGrid('saveRow',row_id)
.editRow(row_id, true,true,reload);
last_selected_row=row_id;
}
}
}
},
答案 0 :(得分:1)
如果您使用单元格编辑,则可以尝试编写执行所需文本替换的beforeSaveCell事件处理程序。
更新:我不知道可以在单元格中放置哪些信息,但可能使用Masked Input Plugin(请参阅旧答案here)或仅仅是'按键'过滤(请参阅another answer)可以改善用户体验。