-1

I used info in this question, I put the mentioned properties directly in the field properties not through a function like this :

{
    name:'A_ORG_SECTOR',
    index:'A_ORG_SECTOR',
    align: 'left',
    width:80,
    sortable:true,
    search:true,
    stype:'select',
    editable:false,
    cellEdit: false ,
    formatter:'select',
    searchoptions: {
        sopt:['eq'],
        value: ':All;1:IT;2:Strategy'
    }
},

... drop down appears correctly but the column values are now cleared @ loading as per the attached image ... any help ???

enter image description here

jquery version : 1.9.1

jqGrid version : 4.5.0

Concerning fork, I am not sure, It's actually part of the liferay libraries, but seems to be the free version.

The values were apearing correctly before converting the search to select instead of text

osama yaccoub
  • 1,884
  • 2
  • 17
  • 47
  • 1
    Please insert always the information about **the version** of jqGrid, which you use (can use), and **the fork** of jqGrid ([free jqGrid](https://github.com/free-jqgrid/jqGrid), commercial [Guriddo jqGrid JS](http://guriddo.net/?page_id=103334) or an old jqGrid in version <=4.7). Moreover if you have problem with **initial filling** of jqGrid then it's important to post the input data used for filling the grid and some jqGrid options (at least `datatype`, `jsonReader`/`xmlReader`, ...), which are related to reading of the data. – Oleg Jul 06 '17 at 08:43
  • 1
    If's important to understand what do `formatter:'select'`. It works in combination with `editoptions.value` or `formatoptions.value` and not with `searchoptions.value` used only during filtering/searching. – Oleg Jul 06 '17 at 08:46
  • thank you , I removed the `formatter:'select'` and it worked as my target was only searching , neither editing nor formatting – osama yaccoub Jul 06 '17 at 10:27

1 Answers1

0

I suppose that your main reason could be missing editoptions.value (or it could be formatoptions.value in case of usage free jqGrid fork) (see the old documentation):

{
    name:'A_ORG_SECTOR',
    width:80,
    formatter:'select',
    editoptions: { value: '1:IT;2:Strategy' },
    stype:'select',
    searchoptions: {
        sopt:['eq'],
        value: ':All;1:IT;2:Strategy'
    }
},

Additionally you should verify that the input data, used for filing the grid, contains values like 1 and 2 and not the texts IT or Strategy.

The exact behavior of jqGrid could heavy depend on the version of jqGrid, which you use and from the fork of jqGrid. Please insert more full information about the version/fork of jqGrid, which you use.

Oleg
  • 220,925
  • 34
  • 403
  • 798
  • thanks @Oleg ...I added the versions to the question above .. actually the text values are `IT` and `Strategy` , so I used instead `value: ':All;IT:IT;Strategy:Strategy'` , my only target is to search using a dropdown instead of text box, ... but unfortunately It didn't work – osama yaccoub Jul 06 '17 at 10:18
  • @osamayaccoub: You are welcome! Please append the text of your question with the current column definition, which you use. If you want to use `value: ':All;IT:IT;Strategy:Strategy'`, then **the usage of `formatter:'select'` is unneeded. You should remove it**. jqGrid 4.5.0 is more as 4 years old and it's not supported since a long time. I recommend you to use the current free jqGrid 4.14.1. You can load it from CDN. See [here](https://free-jqgrid.github.io/getting-started/index.html) and [the wiki article](https://github.com/free-jqgrid/jqGrid/wiki/Access-free-jqGrid-from-different-CDNs) – Oleg Jul 06 '17 at 10:27
  • I removed it and it worked ... It's a legacy code that I have no control on ... thanks alot – osama yaccoub Jul 06 '17 at 10:29
  • please add the part of removing `formatter:'select'` to the main answer so that when I accept it it becomes correct reference for any future search .. what do you think? – osama yaccoub Jul 06 '17 at 10:45
  • If I want to use `dataurl` to get values dynamically, do I need to use `formatter:'select'` ? – osama yaccoub Jul 06 '17 at 10:47
  • @osamayaccoub: I can do this, but my current answer corresponds the text of your current question. The question don't contains any test data or any information, that you don't use `1` or `2` in the input data. Moreover, I wrote in my answer that `formatter:'select'` **require** `editoptions.value`. The setting `formatter:'select', editoptions: { value: 'IT:IT;IT:Strategy' }` will be unneeded, but it should still work. Do you used correct `editoptions.value` in your last tests? – Oleg Jul 06 '17 at 10:54
  • @osamayaccoub: About `dataUrl`. I think that you still not understand what `formatter:'select'` do. Formatter is responsible for **formatting** of input data. Do you read [the link](http://www.trirand.com/jqgridwiki/doku.php?id=wiki:predefined_formatter#formatter_type_select), which I referenced? If you get in input data values like `1` and `2`, but you need *to display another texts in grid* instead of `1` and `2` then you should use `formatter:'select'`. Additionally If you want to filter in the column, then the search request should contains `1` and `2` instead of `IT` and `Strategy`. – Oleg Jul 06 '17 at 11:01