Reputation: 6249
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
Upvotes: 1
Views: 1376
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
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