1

So, in my ASP.NET MVC 3 app, I've got pages with jqGrids on them. I've customized the search operations on a per-column basis like so:

colModel: [
   { name: 'IceCreamName', index: 'IceCreamName', align: 'left',
     searchoptions: {sopt: ['eq', 'ne', 'cn']} },
.
.
.
   { name: 'InitialDate', index: 'InitialDate', align: 'left',
     searchoptions: {sopt: ['eq', 'ne', 'gt', 'lt', 'ge', 'le']} },
   { name: 'Volume', index: 'Volume', align: 'left',
     searchoptions: {sopt: ['eq', 'ne', 'gt', 'lt', 'ge', 'le']} }

]

And that'll give me, for this example, Equal, NotEqual, Contains on the name, and Equal, NotEqual, GreaterThan, LessThan, GreaterThanOrEqual and LessThanOrEqual on the date and volume columns. Wonderful. That customization is great.

What I'd particularly like to do though is customize the strings displayed in the search operation dropdown for those columns. For instance, for the InitalDate column, I'd like the 'gt' to display "after" instead of "greater" (makes more sense to the user) and something like "on or before" instead of "less or equal".

I see that I can modify those globally in the grid.locale-en.js (or whatever locale is correct) but that is at a global level. I'd like the date and volume columns to have strings that are specific to those columns.

Any way to do that? Perhaps I missed something in the documentation on how to accomplish that.

itsmatt
  • 31,265
  • 10
  • 100
  • 164

1 Answers1

1

You don't wrote which version of jqGrid you use, so I suppose that you use the last 4.0.0 version of jqGrid.

There are no jqGrid option of couse which can make searching dialog like you as want. I find your question very interesting, so I extended the code of my this and this old answers so that it do wat you need.

The demo uses jqGrid where 'invdate' column ('Date' column) has as the searchoptions the following:

searchoptions:{sopt: ['eq', 'ne', 'gt', 'lt', 'ge', 'le'],
               optDescriptions: {eq:'my eq', gt:'after', le:'on or before'}}

The optDescriptions is my extension. I use onInitializeSearch method of the searching dialog where I overwrite reDraw and onchange method of the filter dialog so that the new optDescriptions property will be used. Additionally in the demo like in the previous demos I don't permit to remove the first searching rule and set the focus on the last input field.

I recommend you to place new feature request in the trirand forum to make the feature are implemented in jqGrid per default.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • Yes, it's 4.0. I've put in the feature request and will try out your extension. Thanks for the response! – itsmatt Jun 04 '11 at 20:23