Json数据没有加载到Jqgrid中

时间:2014-08-20 15:14:16

标签: c# javascript jquery json jqgrid

我有一个Jqgrid,我试图加载服务器端Json数据数据没有加载到Jqgrid.I也没有收到任何错误。

这是我的客户端代码..

function getdata() {
    $("#UsersGrid").jqGrid({
        url: 'getGriddahico.ashx',
        datatype: 'json',
        colNames: ['AccountNumber', 'BillNumber', 'BillDate', 'Oprator', 'CallDate', 'Time', 'Destination', 'DialledNumber', 'CallType', 'Duration', 'CallCost', 'PhoneNumber'],
        colModel: [
            { name: 'AccountNumber', width: 100, sortable: true, align: 'center' },
            { name: 'BillNumber', width: 100, sortable: true, align: 'center' },
            { name: 'BillDate', width: 100, sortable: true, align: 'center' },
            { name: 'Oprator', width: 100, sortable: true },
            { name: 'CallDate', width: 100, sortable: true, align: 'center' },
            { name: 'Time', width: 100, sortable: true, align: 'center' },
            { name: 'Destination', width: 100, sortable: true, align: 'center' },
            { name: 'DialledNumber', width: 100, sortable: true, align: 'center' },
            { name: 'CallType', width: 100, sortable: true, align: 'center' },
            { name: 'Duration', width: 100, sortable: true, align: 'center' },
            { name: 'CallCost', width: 100, sortable: true, align: 'center' },
            { name: 'PhoneNumber', width: 100, sortable: true, align: 'center' }   
            ],
            rowNum: 100,
            rowList: [100, 200, 300],
            pager: '#UsersGridPager',
            sortname: 'CallDate',
            viewrecords: true,
            ignoreCase: true,
            sortorder: 'asc',
            autowidth: true,
            toppager: true,
            height: '100%'
});

这是我的客户端代码,以json格式获取数据..

while(rs.Read()){
    if(rc){
        json = json + ",";
    }

    json = json + "\n{";
    json = json + "\"CallCost\":\"" + Convert.ToString(rs["CallCost"]) + "\",";
    json = json + "\"cell\":[" + Convert.ToString(rs["CallCost"]) + "";
    json = json + ",\"" + Convert.ToString(rs["AccountNumber"]) + "\"";
    json = json + ",\"" + Convert.ToString(rs["BillNumber"]) + "\"";
    json = json + ",\"" + Convert.ToString(rs["BillDate"]) + "\"";
    json = json + ",\"" + Convert.ToString(rs["Oprator"]) + "\"";
    json = json + ",\"" + Convert.ToString(rs["CallDate"]) + "\"";
    json = json + ",\"" + Convert.ToString(rs["Time"]) + "\"";
    json = json + ",\"" + Convert.ToString(rs["Destination"]) + "\"";
    json = json + ",\"" + Convert.ToString(rs["DialledNumber"]) + "\"";
    json = json + ",\"" + Convert.ToString(rs["CallType"]) + "\"";
    json = json + ",\"" + Convert.ToString(rs["Duration"]) + "\"";
    json = json + ",\"" + Convert.ToString(rs["CallCost"]) + "\"";
    json = json + ",\"" + Convert.ToString(rs["PhoneNumber"]) + "\"]";
    json = json + "}";

    rc=true;
}

json = json +"]\n";

json = json +"}";

HttpContext.Current.Response.Write(json);

请帮我解决这个问题。谢谢..

0 个答案:

没有答案