如何使用 jqGrid 在查询字符串周围添加单引号

发布于 2024-11-28 23:49:40 字数 561 浏览 1 评论 0原文

我正在使用 jqGrid 向用户显示一些数据。我希望这个网格可以排序,但是 jqGrid 发送的数据并不完全是我需要的。

这是 jqGrid 现在发送的查询字符串:

http://local/MyService.svc/GetData?_search=false&nd=1313069918597&rows=50&page=1&sidx=ColumnName&sord=asc

但我的服务需要它是:

http://local/MyService.svc/GetData?_search=false&nd=1313069918597&rows=50&page=1&sidx='ColumnName'&sord='asc'

注意 ColumnNameasc 周围的单引号

有大量的 jqGrid 选项,但我没有找到了任何允许我以这种方式操作查询字符串参数的东西。非常感谢任何帮助!

I'm using jqGrid to display some data to users. I want this grid to be sortable, but the data jqGrid sends isn't exactly what I need.

Here is the query string jqGrid sends now:

http://local/MyService.svc/GetData?_search=false&nd=1313069918597&rows=50&page=1&sidx=ColumnName&sord=asc

But my service needs it to be:

http://local/MyService.svc/GetData?_search=false&nd=1313069918597&rows=50&page=1&sidx='ColumnName'&sord='asc'

Notice the single quotes around ColumnName and asc

There are tons of jqGrid options and I haven't found anything that allows me to manipulate the querystring parameters in this way. Any help is much appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

软糯酥胸 2024-12-05 23:49:40

jqGrid 有 serializeGridData 事件/参数可以帮助您解决服务器请求定制的任何问题。在您的情况下, serializeGridData 可能如下所示

serializeGridData: function (postData) {
    var myPostData = $.extend({}, postData); // make a copy of the input parameter
    myPostData.sidx = "'" + myPostData.sidx + "'";
    myPostData.sord = "'" + myPostData.sord + "'";
    return myPostData;
}

There are serializeGridData event/parameter of jqGrid which can help you solve any problems of customization of the server requests. In your case the serializeGridData could looks as following

serializeGridData: function (postData) {
    var myPostData = $.extend({}, postData); // make a copy of the input parameter
    myPostData.sidx = "'" + myPostData.sidx + "'";
    myPostData.sord = "'" + myPostData.sord + "'";
    return myPostData;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文