0

結合した 2 つのテーブルがあります。このクエリからデータを取得し、jqgrid に表示します。通常、私のグリッドは次のようになります。

ここに画像の説明を入力

ヘッダー (colNames) のような最初の列 (C02/ C01 /C01/ C02 /C01) と 2 番目の列 (2.2.2.2 / 1.1.1 /1.1.1 / 8.8.8.8. / 6.6.6.6) の値を表示したい最初の列と2番目の列のような他の列のヘッダーの下に座っています。確かに、水平グリッドを垂直に変更するつもりです(私は思う)。私のjqGridコードは以下の通りです:

<script type="text/javascript">
var searchOptions = ['eq', 'ne', 'lt', 'le', 'gt', 'ge', 'bw', 'bn', 'in', 'ni', 'ew', 'en', 'cn', 'nc'];

$(document).ready(function () {
    $('#list').jqGrid({
        caption: "ObisData",
        //url from wich data should be requested
        url: '@Url.Action("GetObisData", "DataGrid")',
        //EditData
        editurl: '@Url.Action("EditData", "DataGrid")',
        //type of data
        datatype: 'json',
        jsonReader: {
            root: "Rows",
            page: "Page",
            total: "Total",
            records: "Records",
            repeatitems: true,
            id: "ObisDataID",
            cell: "RowCells"
        },
        //url access method type
        mtype: 'POST',
        //columns names
        colNames: [ '', '', '', ''],
        //columns model
        colModel: [
            {
                name: 'ObisDataID', index: 'ObisDataID', align: 'right', width: 100,
                editable: false, hidden: true, key: true

            },
        {
            name: 'ObisInfoTitle', index: 'ObisInfoTitle', align: 'center', width: 100,
            editable: false, hidden: false

        }
        ,

        {
            name: 'ObisData', index: 'ObisData', align: 'center', width: 100,
            editable: false, hidden: false
        }
        ,
        {
            name: 'ObisInfoTranslateT', index: 'ObisInfoTranslateT', align: 'center', width: 170,
            editable: false, hidden: false
        }

        ],
        //pager for grid
        pager: $('#pager'),
        //number of rows per page
        rowNum: 10,
        rowList: [10, 20, 50, 100],
        //initial sorting column
        sortname: 'ObisDataID',
        //initial sorting direction
        sortorder: 'desc',
        //we want to display total records count
        viewrecords: true,
        altRows: true,
        shrinkToFit: false,
        width: '1100',
        height: 'auto',
        hidegrid: false,
        direction: "rtl",
        gridview: true,
        rownumbers: true,
        footerrow: true,
        //userDataOnFooter: true,
        loadComplete: function () {
            //change alternate rows color
            $("tr.jqgrow:odd").css("background", "#E0E0E0");
        },
        loadError: function (xhr, st, err) {
            jQuery("#rsperror").html("Type: " + st + "; Response: " + xhr.status + " " + xhr.statusText);
        }
        //, loadonce: true
    })
4

1 に答える 1

0

方向コードを変更します。その後、グリッドは左から右に整列します

direction : "ltr"

行番号を変更したくない

rownumbers: false

DB からのヘッダー名

jqgrid コードに colNames を追加した後、最初に js 変数に DB 値を割り当てます。

var firstColName={insert DBvalue data};
var secondColName={insert DBvalue data};
var thirdColName={insert DBvalue data};

 colNames: [ firstColName, secondColName,thirdColName, ......],
于 2015-05-19T08:04:57.860 に答える