3

次のオプションを備えた単純なグリッドがあります。

jQuery("#mygrid").jqGrid({
   url: 'dataurl.htm',
   datatype: 'json',
   ajaxSelectOptions: { cache: false }
   ...
   colModel: [
    { name: 'foo', index: 'foo', width: 25, stype: 'select', searchoptions:{ sopt:       
     ['eq'], dataUrl: 'someurl.htm?columnName=foo'}}
    ]
});

ただし、呼び出す$("#mygrid").trigger("reloadGrid");と、テーブルのデータはからロードされるだけで、列のデータはリンクからdataurl.htmロードされません。foosome url.htm

私はSOでこれらのようないくつかの質問を読みました、そしてそれは持っていることが提案されました、ajaxSelectOptions: { cache: false }しかしこれは私のために働いていません。

someurl.htmリターン_<select> <option val=''>something</option></select>

4

1 に答える 1

3

それは絶対に正しい質問です!jqGridの現在の実装にはtoggleToolbar、ツールバーを非表示にできるメソッドしかありませんが、ツールバー自体は一度作成されます。したがって、ツールバーのすべてのプロパティは常に変更されません。

この問題を解決するために、私destroyFilterToolbarは非常に簡単な小さな追加のメソッドを作成しました。

$.jgrid.extend({
    destroyFilterToolbar: function () {
        "use strict";
        return this.each(function () {
            if (!this.ftoolbar) {
                return;
            }
            this.triggerToolbar = null;
            this.clearToolbar = null;
            this.toggleToolbar = null;
            this.ftoolbar = false;
            $(this.grid.hDiv).find("table thead tr.ui-search-toolbar").remove();
        });
    }
});

デモではこの方法を使用します。一部の列のプロパティを変更した後、検索ツールバーを再作成できます。以下のコードでは、検索ツールバーから一部のテキストの言語を変更できます。

ここに画像の説明を入力してください

対応するコードは次のとおりです。

$("#recreateSearchingToolbar").change(function () {
    var language = $(this).val();

    // destroy searching toolbar
    $grid.jqGrid("destroyFilterToolbar");

    // set some searching options
    $grid.jqGrid("setColProp", "closed",
        language === "de" ?
                {searchoptions: {value: ":Beliebig;true:Ja;false:Nein"}} :
                {searchoptions: {value: ":Any;true:Yes;false:No"}});
    $grid.jqGrid("setColProp", "ship_via",
        language === "de" ?
                {searchoptions: {value: ":Beliebig;FE:FedEx;TN:TNT;IN:Intim"}} :
                {searchoptions: {value: ":Any;FE:FedEx;TN:TNT;IN:Intim"}});

    // create new searching toolbar with nes options
    $grid.jqGrid("filterToolbar", {stringResult: true, defaultSearch: "cn"});
});
于 2012-12-04T09:57:23.443 に答える