jqgrid不会加载所有行

时间:2015-10-26 05:39:25

标签: javascript asp.net jqgrid

我使用了以下内容:ASP .Net 2008 3.5 Webforms / Teradata数据库。 使用的浏览器:IE 9,Firefox

我最多可以加载1700行,但不能加载整个2000多行。 没有错误返回请帮我解决这个问题。如果我错过了以下任何参考和代码,请提供建议:

<link href="CSS/jquery-ui-1.9.2.custom.css" rel="stylesheet" type="text/css" />
<link href="CSS/ui.jqgrid.css" rel="stylesheet" type="text/css" />
<script src="Script/jquery-1.8.3.js" type="text/javascript"></script>
<script src="Script/jquery-ui-1.9.2.custom.js" type="text/javascript"></script>
<script src="Script/grid.locale-en.js" type="text/javascript"></script>
<script src="Script/jquery.jqGrid.min.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript" >
    $(function() {
        $("#dataGrid").jqGrid({
            url: 'UploadHistory.aspx/DisplayListToJQGrid',
            datatype: 'json',
            mtype: 'POST',
            serializeGridData: function(postData) {
                return JSON.stringify(postData);
            },
            ajaxGridOptions: { contentType: "application/json; charset=utf-8" },
            colNames: ['Liability', 'Channel_Lvl_2_Desc'],
            colModel: [
                            { name: 'Liability', index: 'Liability', width: 300 },
                            { name: 'Channel_Lvl_2_Desc', index: 'Channel_Lvl_2_Desc', width: 200 },
                            //{ name: 'T_ADDS', index: 'T_ADDS', width: 200 }
            ],
            pager: '#pagingGrid',
            rowNum: 10,
            rowList: [10, 20, 100],
            viewrecords: true,
            gridview: true,
            width: 780,
            rownumbers: true,
            loadonce: true,
            jsonReader: {
                page: function(obj) { return 1; },
                total: function(obj) { return 1; },
                records: function(obj) { return obj.d.length; },
                root: function(obj) { return obj.d; },
                repeatitems: false,
                id: "0"
            },
            caption: 'Data List'
        });
    });
</script>

                                                                                                                                                                                                                                                                             


                                           

<WebMethod()> _
Public Shared Function DisplayListToJQGrid() As List(Of Dictionary(Of String, Object))

    Return UploadClass.LoadListToJQGrid()

End Function

<WebMethod()> _
Public Shared Function LoadListToJQGrid() As List(Of Dictionary(Of String, Object))

    Dim cmdQry As String = ""

    cmdQry = "SELECT TOP 1970 Liability, Channel_Lvl_2_Desc FROM TABLENAME" 

    Return DataAccessClass.GetListFromDB(cmdQry)

End Function


<WebMethod()> _
Public Shared Function GetListFromDB(ByVal Sql As String) As List(Of Dictionary(Of String, Object))


    Dim dt As New DataTable

    Dim cmd As New Teradata.Client.Provider.TdCommand(Sql, DBConnectionClass.pTDConobj)
    Dim da As New TdDataAdapter(cmd)
    da.Fill(dt)

    'Dim serializer As System.Web.Script.Serialization.JavaScriptSerializer = New System.Web.Script.Serialization.JavaScriptSerializer
    Dim rows As New List(Of Dictionary(Of String, Object))()
    Dim row As Dictionary(Of String, Object) = Nothing

    For Each dr As DataRow In dt.Rows
        row = New Dictionary(Of String, Object)()
        For Each col As DataColumn In dt.Columns
            row.Add(col.ColumnName.Trim(), dr(col).ToString())
        Next
        rows.Add(row)
    Next

    Dim serializer As System.Web.Script.Serialization.JavaScriptSerializer = New System.Web.Script.Serialization.JavaScriptSerializer()
    serializer.Serialize(rows)

    Return rows

End Function

1 个答案:

答案 0 :(得分:1)

我认为你有纯粹的服务器端问题。您使用WebMethod返回JSON数据。您可以在jsonSerialization maxJsonLength="50000000"/>的相应位置添加web.config之类的内容来增加限额。有关详细信息,请参阅https://docs.angularjs.org/api/ng/filter/json

我建议您在jqGrid中另外包含loadError回调,以查看错误,例如#34;使用JSON JavaScriptSerializer进行序列化或反序列化时出错。字符串的长度超过maxJsonLength属性上设置的值。&#34;有关使用loadError回调的详细信息,请参阅the answer