I want to implement filtering in my jqgrid in my spring mvc3.0 project but I can't find any sample code or documentation telling how to use filtering in this.
Could you please point me in the right direction? Thanks.
I want to implement filtering in my jqgrid in my spring mvc3.0 project but I can't find any sample code or documentation telling how to use filtering in this.
Could you please point me in the right direction? Thanks.
I just posted an answer on the same question (probably from you) on http://www.trirand.com/blog/?page_id=393/help/jqgrid-filtering. To make other people easy to read the answer I post the same information here.
The answer on your question depends a little how you interpret the "filtering". If you want use some external controls (selects, checkboxes and so on on the same page where you have jqGrid) to filter your data I recommend you to read http://stackoverflow.com/questions/2928371/how-to-filter-the-jqgrid-data-not-using-the-built-in-search-filter-box/2928819#2928819
If you want to implement data filtering inside of jqGrid you can choose between serching with respect of "search" and reset of serching results with respect of "refresh" buttons of the navigator (simple searching and advanced searching), the usage of toolbar searching (conside the usage of stringResult: true
to be more conform with other form of searching) and custom searching.
If you deceide to use advance searching you can just add string filter
parameter to the (see http://stackoverflow.com/questions/3318277/guidance-on-a-better-way-to-retain-filtering-options-when-using-asp-net-mvc-2/3371155#3371155) action which provide the grid data or add three string parameters searchField
, searchString
, searchOper
if you want to use simple searching feature. In all cases you will have to add WHERE
to the SELECT
statments which will be constructed in your program based on the values of the new parameters.
Probably other people post you more urls to the good full code examples which you could use.
UPATED: I don't use Spring Framework myself, so I could not help you with any Spring MVC 3.0 examples. Some general solution is more common. For example in ASP.NET MVC solutions I prefer don't fill the data in the grid directly using MVC. Instead of that I provide a JSON web service (implemented as a part of ASP.NET MVC solutions or as WFC service which are the part of the same web site) which uel I place in jqGrid parameter. So you should just invest in the writing on business logic in form of JSON/XML web service which provide the data. The most jqGrid specific code you can write in JavaScript. So you can share the experience of other people in the usage of jqGrid and have a clear separation of HTML code from the business logic. Moreover JSON/XML web services can be better tested for example with respect of unit tests.