重装jqGrid的异步使用Asp.Net MVC时,并通过搜索/过滤标准 [英] Reloading JQGrid asynchronously when using Asp.Net MVC and passing search/filter criteria

查看:126
本文介绍了重装jqGrid的异步使用Asp.Net MVC时,并通过搜索/过滤标准的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是JQSuite的Trirand.Web.MVC DLL我整合的jqGrid进我的MVC 3应用程序。

I am using the JQSuite's Trirand.Web.MVC dll for my integration of JQGrid into my MVC 3 application.

我使用的jqGrid的HTML帮助,所以我认为我有以下几点:

I am using the HTML helper for JQGrid, so in my View I have the following:

@Html.Trirand().JQGrid(Model.MyGrid, "Grid")

我知道我可以通过以下code重装上的按钮,点击我的网格:

I know I can reload my grid on a button click by using the following code:

$("#Grid").trigger("reloadGrid");

这将刷新网格,要求我在位指示code指定设立jqGrid的操作方法。

This WILL reload the grid, calling the Action method I specified in my contoller code for setting up the JQGrid.

我有我使用的搜索/过滤页面上的其他控件,这些获得通过的行动方法很好。

I have other controls on the page that I use for searching/filtering, these get passed to the action method fine.

我找到了setGridParam方法,这似乎表明,你可以这样做:

I found the setGridParam method, which seems to indicate you can do something like:

$("#Grid").setGridParam({ someParam: 'blah' }).trigger("reloadGrid");

或本

$("#Grid").jqGrid('setGridParam', { postData: { someParam: 'somevalue'} }).trigger("reloadGrid");

但在我的操作方法我someParam参数没有得到填充两种方法

but my someParam parameter on my action method does not get filled with either method

如何设置这些在jqGrid的,让他们通过行动的方法去重装拾取?

How can I set these on the JQGrid so that they are picked up by Action method when doing the reload?

更新
现在我已经尝试了另一种参数这种方法和它的工作!

UPDATE: I have now tried this method for another parameter and it DOES work!

所以现在我有:

$("#Grid").jqGrid('setGridParam', { postData: {
            someParam: 'somevalue', 
            paramTwo: ' some value',
            paramThree: 'some other value'
        } }).trigger("reloadGrid");

someParam不起作用,但paramTwo和ParamThree做的工作。

someParam does not work, but paramTwo and ParamThree DO work.

奇怪了!

什么能停止工作的一个参数?

What could stop one parameter from working?

UPDATE2:
使用奥列格的建议如下:

UPDATE2: Using Oleg's suggestion as follows:

var myGrid = jQuery("#Grid").jqGrid({                
                postData: {
                    someParam: function () { return $("#txtBox1").val(); },
                    paramTwo: function () { return $("#txtBox2").val(); },
                    paramThree: function () { return $("#txtBox3").val(); }
                }
            });

        myGrid.trigger('reloadGrid'); 

...值没有打通发送。我已经验证了的JQuery它在重装前返回正确的值。

...NONE of the values get sent through. I have validated the JQuery returns the correct values before it does the reload.

推荐答案

右键,非常感谢OLEG对他的帮助,因为它使我一个答案!

Right, many thanks to OLEG for his help as it led me to an answer!

问题被SomeParam已经在后的数据指定的,所以我不得不用这种形式来扩展现有的数据:

The issue was "SomeParam" was already specified in the post data so I had to extend the existing data using this form:

('#grid').jqGrid({                 
                serializeGridData: function(postData) { 
                  var newPostData = $.extend(postData, {
                      someParam: return $("#txtBox1").val(), 
                      paramTwo: return $("#txtBox1").val(),
                      paramThree: return $("#txtBox1").val(),
                  }); 

                  return $.param(newPostData); 
                } 
            }).trigger("reloadGrid");

这<一个href=\"http://stackoverflow.com/questions/8612800/jquery-jqgrid-postdata-overriding-default-values\">post帮我出这一点,也奥列格张贴在那里了。

this post helped me out with this, Oleg also posting over there too.

这篇关于重装jqGrid的异步使用Asp.Net MVC时,并通过搜索/过滤标准的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆