开发者

JQGrid do not hit the DB server when onSortCol or onPAging

I have a grid that shows 50 rows out of 50000 every time the grid goes to the server it runs the method public ActionResult CreateGrid(string sidx, string sord, string page, string rows, bool gridEvent.... this method always get the 50000 roes then shows just the 50 records corresponding to the current page. I've added a static list where I maintain the 50000 records and I've added a gridEvent var on the UI to indicate if it is a gridEvent from onSortCol or onPAging or just a postback from submit button.

Code on the grid to modify the input gridEvent with the TRUE value when onPaging or onSortCol

 onPaging: function (pgButton) {
                $("#gridEvent").val("true");
            },
            onSortCol: function (index, iCol, sortorder) {
                $("#gridEvent").val("true");
            },

Code to modify the input gridEvent with the FALSE value when hitting the submit button.

 function SubmitForm() {
    $("#getReport").validate()
    if($("#getReport").valid()) {
        $("#gridEvent").val("false");
        $("#getReport").submit()
    }
}

Everything seems to be right but when I look on the bool gridEvent开发者_如何学运维 on the Server method it is always false. If I did not change gridEvent input type value on function SubmitForm() the value on the server always comes true. How can I do to get the correct value, when I do a grid event or when I submit the form?


You included the following declaration of the server Action in your question

public ActionResult CreateGrid(string sidx, string sord, string page, string rows,
                               bool gridEvent....

so you post the value gridEvent in some way, but you don't included the corresponding code. So I can only guess.

If you use for example just

postData: {
    gridEvent: $("#gridEvent").val()
}

it could be your problem because the $("#gridEvent").val() will be executed once at the grid initialization (creation). The correct usage could be

postData: {
    gridEvent: function() { return $("#gridEvent").val(); }
}

see here for more information.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜