0

I can't find a way to set search options for a column? It seem they are set by default and there's no way I can change it.

We have this option in Jqgrid:

{ name: "outputid", index: "outputid", width: 30, searchoptions: { sopt: ['eq']} }

When doing this in MvcJqGrid:

.AddColumn(new Column("promoDate").SetAlign(MvcJqGrid.Enums.Align.Center).SetLabel("Fecha Ingreso").SetSearchType(Searchtype.Datepicker).SetSearchDateFormat("yy-mm-dd"))

I receive a 'bw' as rule op, not 'eq' as I would like to set.

Thanks!

Sanchitos
  • 8,423
  • 6
  • 52
  • 52

2 Answers2

3

I've updated MvcJqGrid (nuget package is also updated). As of now you can set a searchoption per column with 'SetSearchOption'. Your example would look something like this:

.AddColumn(new Column("promoDate")
  .SetAlign(MvcJqGrid.Enums.Align.Center)
  .SetLabel("Fecha Ingreso")
  .SetSearchType(Searchtype.Datepicker)
  .SetSearchDateFormat("yy-mm-dd")
  .SetSearchOption(SearchOptions.Equal))

Let me know if this works for you.

Robin van der Knaap
  • 4,060
  • 2
  • 33
  • 48
  • @Robin van der Knaap, no it does not, about 5 minit ago i updated with nuget and it does not work. I need SearchOption too, pls help – Roar May 10 '13 at 07:47
  • @Roar Could you explain what doesn't work? You can create an issue on github with some sample code. https://github.com/robinvanderknaap/MvcJqGrid/issues?direction=desc&sort=created&state=open – Robin van der Knaap May 10 '13 at 07:56
  • and if we have SearchOptions enum, why don't we have MvcJqGrid.Rule property op as enum type, now it's string – Roar May 10 '13 at 07:56
  • @RobinvanderKnaap in my razor engine i can not .SetSearchOption(SearchOptions.Equal) there is no option in intellisense – Roar May 10 '13 at 08:01
  • Can you confirm you are using version 1.0.11? Can you try: .SetSearchOption(MvcJqGrid.Enums.SearchOptions.Equal)) – Robin van der Knaap May 10 '13 at 08:06
  • You can also add MvcJqGrid.Enums to the web.config in your views folder: – Robin van der Knaap May 10 '13 at 08:07
0

First of all I should mention that I don't use MvcJqGrid myself. It's really important to set different sopt option for different columns especially if one uses toolbar searching. It seems that MvcJqGrid don't provide you enough possibilities to do this. Nevertheless it looks so that MvcJqGrid generate some JavaScript code for you. So if you can't generate exactly the code which you need then you can still change some properties of grid later. For example

$("#grid").jqGrid("setColProp", "outputid", { searchoptions: { sopt: ['eq']} });

change the properties of "outputid" column. It is important to make the changes before searching toolbar are created (before method filterToolbar) will be called. If you can't inject your JavaScript code before creating searching toolbar you can recreate it later with modified properties using destroyFilterToolbar method (see the answer and the pull request):

$("#grid").jqGrid("destroyFilterToolbar");
$("#grid").jqGrid("filterToolbar", { stringResult: true, defaultSearch: "cn" });
Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798