jqgrid 内联编辑显示 nbsp;而不是一列的空格
Jqgrid inline edit displays nbsp; instead of spaces for one column
jqgrid 列包含 phone 个数字。
对于一行,如果内联编辑已开始,将出现
个字符而不是空格:
之前:
编辑开始后:
保存后nbsp;也保存在phone号。
如何修复或诊断此问题?
如果使用表单编辑,也会出现这些字符。
phone 数字也包含空格的其他行会正确显示。此行中的其他列也正确显示。
本栏目colmodel:
{"label":"Telefon","name":"Telefon","index":"Telefon","editoptions":{"maxlength":25,"size":25,"dataEvents":[{"type":"change","fn":function(e) {dataChanged(e.target)}
},{"type":"focus","fn":function(e) {if(typeof e.target.ischanged=='undefined') {e.target.ischanged=false}}
}],"readonly":null,"class":null,"disabled":null},"editable":true,"width":66,"classes":null,"hidden":false,"searchoptions":{"sopt":["cn","eq","ne","lt","le","gt","ge","bw","ew","nc"]},"stype":"text"},
jqgrid 由 json 服务器中的数据填充:
{"total":1,"page":1,"rows":[{"id":"7","cell":[null,"","7","XXXanval Mll OÜ","Tarnija","","","","","","","","","","3 725 141 100","","","Ursel","","","","","","","","","","02","",""]}]}
其他正确填充的行包含类似的数据,可能会填充更多的列。
jqgrid 设置:
$.extend($.jgrid.defaults, {
mtype: 'POST',
toppager: true,
viewrecords: false,
recordpos: 'center',
pagerpos: 'right',
rowList: [50, 500, 1000],
rowNum: 50,
rownumbers: true,
onSelectRow: grid_onSelectRow,
onSelectAll: grid_onSelectAll,
multiselect: true,
ajaxRowOptions: { async: true },
scrollrows: true,
prmNames: {
id: "_rowid", page: "_page", rows: "_rows", oper: "_oper", sort: "_sidx", order: "_sord",
nd: "_nd"
},
loadui: 'block',
cmTemplate: { fixed: true },
autoencode: true,
gridview: true,
...
问题存在于您的输入数据中。你提出了不正确的数据。真实数据已经包含non-breaking space。您的服务器返回的 JSON 数据是 而不是 "3 725 141 100"
(里面有 space,space 的代码是 32 或 0x20 ),但是 "3 725 141 100"
(里面有 non-breaking spaces,代码为 160 或 0xA0)。
HTTP 流量中的 UTF-8 编码数据看起来像
解码后的数据看起来像
上图显示了您的原始 JSON 数据以 HEX 格式显示的片段。我用绿色标记了标准 space,用红色标记了从您的服务器返回的数据中使用的 space。要解决此问题,您应该在数据库或服务器代码中或在 JavaScript 代码中的客户端规范化数据。无论如何,您应该将所有不需要的 non-breaking space 替换为标准的 space.
jqgrid 列包含 phone 个数字。
对于一行,如果内联编辑已开始,将出现
个字符而不是空格:
之前:
编辑开始后:
保存后nbsp;也保存在phone号。 如何修复或诊断此问题?
如果使用表单编辑,也会出现这些字符。 phone 数字也包含空格的其他行会正确显示。此行中的其他列也正确显示。
本栏目colmodel:
{"label":"Telefon","name":"Telefon","index":"Telefon","editoptions":{"maxlength":25,"size":25,"dataEvents":[{"type":"change","fn":function(e) {dataChanged(e.target)}
},{"type":"focus","fn":function(e) {if(typeof e.target.ischanged=='undefined') {e.target.ischanged=false}}
}],"readonly":null,"class":null,"disabled":null},"editable":true,"width":66,"classes":null,"hidden":false,"searchoptions":{"sopt":["cn","eq","ne","lt","le","gt","ge","bw","ew","nc"]},"stype":"text"},
jqgrid 由 json 服务器中的数据填充:
{"total":1,"page":1,"rows":[{"id":"7","cell":[null,"","7","XXXanval Mll OÜ","Tarnija","","","","","","","","","","3 725 141 100","","","Ursel","","","","","","","","","","02","",""]}]}
其他正确填充的行包含类似的数据,可能会填充更多的列。
jqgrid 设置:
$.extend($.jgrid.defaults, {
mtype: 'POST',
toppager: true,
viewrecords: false,
recordpos: 'center',
pagerpos: 'right',
rowList: [50, 500, 1000],
rowNum: 50,
rownumbers: true,
onSelectRow: grid_onSelectRow,
onSelectAll: grid_onSelectAll,
multiselect: true,
ajaxRowOptions: { async: true },
scrollrows: true,
prmNames: {
id: "_rowid", page: "_page", rows: "_rows", oper: "_oper", sort: "_sidx", order: "_sord",
nd: "_nd"
},
loadui: 'block',
cmTemplate: { fixed: true },
autoencode: true,
gridview: true,
...
问题存在于您的输入数据中。你提出了不正确的数据。真实数据已经包含non-breaking space。您的服务器返回的 JSON 数据是 而不是 "3 725 141 100"
(里面有 space,space 的代码是 32 或 0x20 ),但是 "3 725 141 100"
(里面有 non-breaking spaces,代码为 160 或 0xA0)。
HTTP 流量中的 UTF-8 编码数据看起来像
解码后的数据看起来像
上图显示了您的原始 JSON 数据以 HEX 格式显示的片段。我用绿色标记了标准 space,用红色标记了从您的服务器返回的数据中使用的 space。要解决此问题,您应该在数据库或服务器代码中或在 JavaScript 代码中的客户端规范化数据。无论如何,您应该将所有不需要的 non-breaking space 替换为标准的 space.