user595234
user595234

Reputation: 6249

jqgrid to do ajax search

I need to code a grid for search. Please see the screenshot. When user click 'search', it will use ajax to load first page data into grid, then user clicks the page number, it will go to page 2,.... how to design this Ajax ? do you have any prototype ?

I am using jqgrid + JQuery.

Thanks

enter image description here

Upvotes: 1

Views: 1376

Answers (2)

Corneliu
Corneliu

Reputation: 2942

<input type="text" name="ProjectID" id="ProjectID" />
<a href="#" id="SearchBtn">Search</a>

you need to write "beforeRequest" event handler to attach additional parameters to the ajax request:

...
"url": '/SearchUrl'
"beforeRequest" : function DataBrowserGridOnBeforeRequest() {
    $("#TheGrid").jqGrid('setGridParam', { 
        postData: { "searchText": $('#ProjectID').val()}    
    });
}
...

$("SearchBtn").click(function(){
    $("#TheGrid").trigger('reloadGrid');
});

Upvotes: 1

Justin Ethier
Justin Ethier

Reputation: 134167

The grid can do toolbar searching, which is what you are asking for and more. There is a demo online under jqGrid Demos | New in version 3.7 | Tooolbar search .

Does that help at all?

Upvotes: 0

Related Questions