0

我有两个加入的表。我从此查询中获取数据并在 jqgrid 中显示。在正常情况下,我的网格是这样的:

在此处输入图像描述

我想显示第一列 (C02/ C01 /C01/ C02 /C01),如 header(colNames) 和第二列 (2.2.2.2 / 1.1.1 /1.1.1 / 8.8.8.8. / 6.6.6.6) 的值第一列和第二列等其他列并位于标题下方。确实,我要将水平网格更改为垂直(我认为)。我的 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

来自数据库的标题名称

在 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 回答