1

Jqgridに並べ替え列のアイコンを表示する必要があります。私はここで答えを見つけました。それを試してみたところ、並べ替え可能なすべての列ヘッダーに並べ替えアイコンが表示されましたが、デフォルトの並べ替え列には強調表示されたアイコンが表示されていません。

これは私のスクリプトです:

var $tempX= $(divId), colModel, sortName;


    jQuery(divId).jqGrid({
        datatype: "local",
        height: 250,
        width:1000,
        colNames:eval(colNamesVal),
        colModel:eval(colModelVal),
        rowNum:35, 
        rowList:[35,60,100,1000000000],
        rownumbers: true,
        rownumWidth:50,
        height:"auto",
        pager: '#pager2',
        ignoreCase: true,
        //altRows:true,
        pagination:true,
        headertitles:true,
        sortable:true,
        sortorder: "asc",
        viewrecords: true,
        onSortCol: function (index, idxcol, sortorder) {
            if (this.p.lastsort >= 0 && this.p.lastsort !== idxcol
                    && this.p.colModel[this.p.lastsort].sortable !== false) {
                // show the icons of last sorted column
                $(this.grid.headers[this.p.lastsort].el)
                    .find(">div.ui-jqgrid-sortable>span.s-ico").show();
                $(this.grid.headers[this.p.lastsort].el).removeClass('sortedColumnHeader');
            }
            $(this.grid.headers[idxcol].el).addClass('sortedColumnHeader');
        },
        loadComplete: function(){
            $("option[value=1000000000]").text('All');
        } 
    });

colModel = $tempX.jqGrid('getGridParam', 'colModel');
    sortName = $tempX.jqGrid('getGridParam', 'sortname');
    $('#gbox_' + $.jgrid.jqID($tempX[0].id) +
        ' tr.ui-jqgrid-labels th.ui-th-column').each(function (i) {
        var cmi = colModel[i], colName = cmi.name;

        if (cmi.sortable !== false) {
            // show the sorting icons
            $(this).find('>div.ui-jqgrid-sortable>span.s-ico').show();
        } else if (!cmi.sortable && colName !== 'rn' && colName !== 'cb' && colName !== 'subgrid') {
            // change the mouse cursor on the columns which are non-sortable
            $(this).find('>div.ui-jqgrid-sortable').css({cursor: 'default'});
        }
        if (cmi.name === sortName) {
            $(this).addClass('sortedColumnHeader');
        }
    });

誰かがこれを手伝ってくれる?ありがとう!

4

1 に答える 1

0

あなたはおそらく次の私の古い答えを意味します。あなたが使用するものであるデモまたはこれ

デフォルトの並べ替え列に強調表示されたアイコンを表示したいと書いた。問題を解決するにはsortname、グリッドにオプションが必要です。.sortedColumnHeader > divCSS設定を定義することも重要です。デモのようにこれを行うと、すべてが期待どおりに機能します。

于 2012-06-16T08:20:37.107 に答える