Jqrid-搜索对话框-如何本地化groupOps文本值"AND"和"OR"; [英] Jqrid-Search Dialog-How to localize groupOps Text Values "AND" and "OR"

查看:88
本文介绍了Jqrid-搜索对话框-如何本地化groupOps文本值"AND"和"OR";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个jqgrid,它启用了多个搜索功能,并且想将"AND"和"OR"组操作文本更改为它们的母语对应的值.

I have a jqgrid which i enabled multiple search for and i wanna change the "AND" and "OR" group operation texts to their corresponding values in my native language.

我要更改

  • 与VE
  • 或与VEYA

这是我的代码:

    jQuery("#kontrollist").jqGrid('navGrid', '#controllistpager',
      {
        edit: true,
        add: true,
        del : true,
        search: true
      },
      { top: 10, left: 300, jqModal: false, closeOnEscape: true }, // edit options
      {top: 10, left: 300, jqModal: false, closeOnEscape: true, reloadAfterSubmit: true }, // add options
      {top: 100, left: 200, jqModal: false, closeOnEscape: true }, // del options
      // search options
      {
        top: 100, 
        left: 250, 
        jqModal: false, 
        closeOnEscape: true,
        groupOps: [{ op: "AND", text: "all" }, { op: "OR", text: "any"}],
        //showQuery: true,
        multipleSearch: true,
      }, 
      {top: 100, left: 200, jqModal: false, closeOnEscape: true} // view options
    );

我尝试更改

groupOps: [{ op: "VE", text: "all" }, { op: "VEYA", text: "any"}],

groupOps: [{ op: "AND", text: "VE" }, { op: "OR", text: "VEYA"}],

这两个都不起作用. 有没有办法更改这些值?感谢您的任何帮助.

which both didnt work. Is there a way to change these values? Any help is appreciated, thanks in advance.

推荐答案

这是一个好问题!向我+1.

It's a good question! +1 from me.

当前的jqGrid代码使用显示的文本和查询中使用的value属性相同的值来构建对应的<select>元素.作为一种解决方法,我建议您定义函数updateGroupOpText

The current jqGrid code build corresponding <select> element using the same values for the displayed text and the value attribute used in the query. As a workaround I suggest you the define the function updateGroupOpText

var updateGroupOpText = function ($form) {
        $('select.opsel option[value="AND"]', $form[0]).text('My ADD');
        $('select.opsel option[value="OR"]', $form[0]).text('My OR');
        $('select.opsel', $form[0]).trigger('change');
    };

并将其用作onInitializeSearchafterRedraw事件的事件处理程序:

and use it as the event handler for onInitializeSearch and afterRedraw events:

jQuery("#kontrollist").jqGrid('navGrid', '#controllistpager',
    { add: false, edit: false, del: false },
    {}, {}, {},
    { // search options
        multipleSearch: true,
        onInitializeSearch: updateGroupOpText,
        afterRedraw: updateGroupOpText
    }
);

请参见相应的演示此处,该对话框将显示类似以下:

See the corresponding demo here, which displays the dialog like the following:

您应该只将我的添加"和我的OR"更改为所需的文本.

You should just change "My ADD" and "My OR" to the texts which you want.

这篇关于Jqrid-搜索对话框-如何本地化groupOps文本值"AND"和"OR";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆