在jqGrid中使用json rowNum想要输出值

时间:2011-06-24 07:27:03

标签: jquery jqgrid

$(document).ready(function(){
    $("#gridList").jqGrid({
        url:'server.json',
        mtype: 'GET',
        datatype: "json",
        colNames:['NO','DATA', 'CLIENT', 'AMOUNT','TEX','TOTAL','NOTE'],
        colModel:[
            {name:'id',index:'id', width:100,align:"center",key:true,sorttype:'int'},
            {name:'invdate',index:'invdate', width:120,editable:true,sorttype:"date",formatter:'date', formatoptions:{srcformat:"Y-m-d",newformat:"d-M-Y"}},
            {name:'name',index:'name', width:100,editable:true,editoptions:{size:"20",maxlength:"30"}},
            {name:'amount',index:'amount', width:100, align:"right",editable:true,editable:true,editrules:{number:true,minValue:100,maxValue:350},formatter:'currency',formatoptions:{thousandsSeparator:","}},
            {name:'tax',index:'tax', width:100, align:"right",editable:true,edittype:"select",editoptions:{value:"FE:FedEx;IN:InTime;TN:TNT;AR:ARAMEX"}},
            {name:'total',index:'total', width:100,align:"right",editable:true,edittype:"checkbox",editoptions: {value:"Yes:No"}},
            {name:'note',index:'note', width:150, sortable:false,editable:true,edittype:"textarea", editoptions:{rows:"1",cols:"20"}}
        ],
        rowNum:10,
        height:278,
        sortname: 'id',
        sortorder: "asc",
        viewrecords: true,
        multiselect: false,
        editurl: "server.json",
        loadonce:false,
        imgpath: 'style/grid'
    });

    var a = $('#gridList').jqGrid('getGridParam','rowNum');

    alert(a);           // *result --> [object Object]
    alert(a.rowNum);    // *result --> undefined
    alert(parseInt(a)); // *result --> NaN
}

有关如何获得正确值的信息?


server.json文件位于同一文件夹中

server.json:

{
    "page": "1",
    "total": 15,
    "records": "13",
    "rows": [
        {
            "id": "15",
            "cell": [
                "15",
                "2007-10-06",
                "Client 1",
                "200.00",
                "40.00",
                "240.00",
                null
            ]
        },
        {
            "id": "14",
            "cell": [
                "14",
                "2007-10-06",
                "Client 3",
                "200.00",
                "0.00",
                "200.00",
                null
            ]
        },
        {
            "id": "13",
            "cell": [
                "13",
                "2007-10-05",
                "Client 2",
                "120.00",
                "12.00",
                "134.00",
                null
            ]
        },
        {
            "id": "12",
            "cell": [
                "12",
                "2007-10-05",
                "Client 1",
                "50.00",
                "10.00",
                "60.00",
                null
            ]
        },
        {
            "id": "11",
            "cell": [
                "11",
                "2007-10-05",
                "Client 3",
                "100.00",
                "0.00",
                "100.00",
                "no tax"
            ]
        },
        {
            "id": "10",
            "cell": [
                "10",
                "2007-10-06",
                "Client 3",
                "1000.00",
                "0.00",
                "1000.00",
                null
            ]
        },
        {
            "id": "9",
            "cell": [
                "9",
                "2007-10-06",
                "Client 2",
                "700.00",
                "140.00",
                "840.00",
                null
            ]
        },
        {
            "id": "8",
            "cell": [
                "11",
                "2007-10-06",
                "Client 1",
                "600.00",
                "120.00",
                "720.00",
                null
            ]
        },
        {
            "id": "7",
            "cell": [
                "7",
                "2007-10-06",
                "Client 2",
                "100.00",
                "20.00",
                "120.00",
                null
            ]
        },
        {
            "id": "6",
            "cell": [
                "6",
                "2007-10-06",
                "Client 1",
                "200.00",
                "40.00",
                "240.00",
                null
            ]
        },
        {
            "id": "5",
            "cell": [
                "5",
                "2007-10-06",
                "Client 3",
                "200.00",
                "0.00",
                "200.00",
                null
            ]
        },
        {
            "id": "4",
            "cell": [
                "4",
                "2007-10-05",
                "Client 2",
                "120.00",
                "12.00",
                "134.00",
                null
            ]
        },
        {
            "id": "3",
            "cell": [
                "3",
                "2007-10-05",
                "Client 1",
                "50.00",
                "10.00",
                "60.00",
                null
            ]
        },
        {
            "id": "2",
            "cell": [
                "2",
                "2007-10-05",
                "Client 3",
                "100.00",
                "0.00",
                "100.00",
                "no tax"
            ]
        },
        {
            "id": "1",
            "cell": [
                "1",
                "2007-10-04",
                "Client 3",
                "150.00",
                "0.00",
                "150.00",
                "no tax"
            ]
        }
    ]
}

1 个答案:

答案 0 :(得分:0)

如何在the demo上看到一切正常,alert(a)alert(parseInt(a))显示“10”。您可以将我的演示代码与青年代码进行比较,以找出差异。