多个空格在页面上显示的问题,修改jqgrid源码解决

今天客户反馈了一个小问题,就是把表格中的产品名复制到搜索条件里面查询却查不到相应的产品。经过调查以后发现这个产品名包含了三个空格,而在页面上却只显示了一个空格

所以复制后多的空格都缺失了,查询资料后发现这是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,"&nbsp;");//将空格替换成&nbsp;
                            return '<td role="gridcell" ' + p(c, d, b, e, a, f) + ">" + b + "</td>"
                        },

就可以了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值