jqgrid列包含电话号码。
对于一行,如果内联编辑已开始,则会显示
个字符而不是空格:
在:
编辑开始后:
保存后也保存在电话号码中。 如何修复或诊断?
如果使用表单编辑,也会出现这些字符。 电话号码也包含空格的其他行显示正确。此行中的其他列也正确显示。
此列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","",""]}]}
正确填充的其他行包含类似的数据,可能会填充更多的columsn。
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,
...
答案 0 :(得分:1)
输入数据中存在问题。你提出了错误的数据。实际数据已包含 non-breaking space。您的服务器返回的JSON数据是不是 "3 725 141 100"
(内部有空格,空格的代码是32或0x20),但是"3 725 141 100"
(里面有不间断的空格,其代码为160或0xA0。
HTTP流量中的UTF-8编码数据类似于
解码数据看起来像
上图显示了以HEX格式显示的原始JSON数据的片段。我用绿色标记标准空间,用红色标记从服务器返回的数据中使用的空间。要解决此问题,您应该在数据库或服务器代码中或JavaScript代码中的客户端规范化数据。无论如何,您应该将所有不需要的不间断空格替换为标准空间。