简体   繁体   English

使用格式化程序进行JqGrid内联编辑

[英]JqGrid inline editing with formatter

I have this column model 我有这个列模型

{ name: 'CostShare', index: 'CostShare', width: 50, formatter: 'number', formatoptions: { decimalPlaces: 2, suffix: "%" }, resizeable: true, align: 'center', editable: true, edittype: 'text', editOptions: { number: true} }

which will produce a formatted value 1.00% from the source data of 1. Problem is when I do inline editing it turns the formatted data into a textbox. 这将从源数据1生成格式化值1.00%。问题是当我进行内联编辑时,它将格式化数据转换为文本框。 It creates 它创建

<td aria-describedby="AdminCostTable_CostShare" title="1.00%" style="text-align: center;" role="gridcell"><input type="text" style="width: 98%;" id="1_CostShare" name="CostShare" role="textbox" class="editable"></td>

When you escape to close the editing "session" it probably tries to reformat again and turns the 1.00% into NaN. 当您转义以关闭编辑“会话”时,它可能会尝试重新格式化并将1.00%转换为NaN。 Do I have to unformat the data manually or shouldn't the grid be doing that? 我是否必须手动取消格式化数据,或者网格不应该这样做?

I had to use the 我不得不使用

         unformat: unformatPercent

hook in the colModel. 挂钩在colModel中。 Seems like default format options should auto unformat themselves. 看起来像默认格式选项应该自动取消格式化自己。 If it's just me doing something weird let me know. 如果只是我做一些奇怪的事情让我知道。 otherwise this is the answer. 否则这就是答案。

Are you calling editRow() manually in your code? 你在代码中手动调用editRow()吗? If yes, try to call restoreRow() beforehand 如果是,请尝试事先调用restoreRow()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM