Deckard
Deckard

Reputation: 2450

Translate search operators in jqGrid on the fly

Our application has its own translation facility and since jqGrid translations are not complete we are injecting the translations into jqGrid on pager setup.

We are using jqGrid 4.4.4 - updating is currently not an option.

This works fine for almost all translations (see alerttext, etc in the example below).

However for the search filter operators (see odata array below) this does not work at all. The odata strings ("equals", "not equal",...) are not replaced with the translated strings. As said, using the standard jqGrid language files is not an option for us.

Does anybody know how to inject the translation for search operators on the fly?

jQuery("#displayresponses").jqGrid( 'navGrid', '#pager',
        {
            add: false,
            edit: false,
            del: true,
            alertcap: sWarningMsg,
            alerttext: sSelectRowMsg,
            searchtitle : sSearchTitle,
            refreshtitle : sRefreshTitle,
            deltitle : sDelTitle,
            search: true,
            refresh: true,
            view: false,
            position: "left"
        },
        {}, // edit options
        {}, // add options
        {
            msg : strDeleteAllConfirm,
            bSubmit : sDelCaption,
            caption : sDelCaption,
            bCancel : sCancel,
            width : 700
        },
        { // Search options
            caption : sSearchCaption,
            Find : sFind,
            multipleSearch: true,
            odata : [ sOperator1, sOperator2, sOperator3,
                sOperator4, sOperator5, sOperator6,
                sOperator7, sOperator8, sOperator9,
                sOperator10, sOperator11, sOperator12,
                sOperator13, sOperator14 ],
            Reset : sReset,
            width: 700
        }
        
    );

Upvotes: 1

Views: 314

Answers (1)

Oleg
Oleg

Reputation: 221997

You use wrong tag free-jqgrid tag to your question, which follow to misunderstandings. The free-jqgrid tag should be used in case of usage free jqGrid existing in versions 4.8.0, ... 4.13.2.

The retro version 4.4.4 use $.jgrid.search.odata as the parameter of jqFilter instead of odata option introduced later. Thus you have to change $.jgrid.search.odata "on the fly".

The old version 4.4.4 is dead and I would strictly recommend you to upgrade to the current free jqGrid 4.13.2. You can use it directly from CDN like it's described in the wiki atricle and additionally included in the README of all last published versions of free jqGrid. If you would do prefer to use NuGet package then you can uninstall old jQuery.jqGrid package and install free-jqGrid instead.

Upvotes: 1

Related Questions