今天客户反馈了一个小问题,就是把表格中的产品名复制到搜索条件里面查询却查不到相应的产品。经过调查以后发现这个产品名包含了三个空格,而在页面上却只显示了一个空格
所以复制后多的空格都缺失了,查询资料后发现这是html页面的特性。
解决方法是用 代替空格
经过debug后找到jqgrid.js中拼接文本的代码
x = function (c, d, e, f, g) {
var h = a.p.colModel[e];
void 0 !== h.formatter ? (c = "" !== String(a.p.idPrefix) ? b.jgrid.stripPref(a.p.idPrefix, c) : c, c = {
rowId: c,
colModel: h,
gid: a.p.id,
pos: e
},
d = b.isFunction(h.formatter) ? h.formatter.call(a, d, c, f, g) : b.fmatter ? b.fn.fmatter.call(a, h.formatter, d, c, f, g) : q(d)) : d = q(d);
return d
},
G = function (a, b, c, d, e, f) {
b = x(a, b, c, e, "add");
return '<td role="gridcell" ' + p(c, d, b, e, a, f) + ">" + b + "</td>"
},
改成
G = function (a, b, c, d, e, f) {
b = x(a, b, c, e, "add");
if(typeof b == "string")
b = b.replace(/\s/g," ");//将空格替换成
return '<td role="gridcell" ' + p(c, d, b, e, a, f) + ">" + b + "</td>"
},
就可以了