0

I used the following : ASP .Net 2008 3.5 Webforms/Teradata Database. Browser used : IE 9, Firefox

I am able to load up to 1700 rows but not the whole 2000+ records. No error is returned Please help me solve this one. Please advice if I have missed any reference and code below :

<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
EdwinP
  • 1
  • 4
  • can you make javascript legible? – Rakin Oct 26 '15 at 05:44
  • I don't think that it's good idea. No user are able to look through 1 million cells. So you want to send 99,9% unneeded data to the client. What you really need is implementation of the subject oriented filtering of the data.The performance of the grid will be mostly depend from the JavaScript engine of the web browser which you use. In any way I am sure that you have to implement paging, sorting and filtering on the server side. I think it's really required in case of 1 million cells of data. – Rakin Oct 26 '15 at 05:49
  • Im sorry this is my first time using this site. – EdwinP Oct 26 '15 at 06:00
  • Hi Rakin I already update my question. Also I am not trying to display all the rows in one page. I only display 10 rows per page and want to load all the 2000 + records to jqgrid. After I pass 2000+ rows from Teradata, no rows where displayed and no error is returned. – EdwinP Oct 26 '15 at 06:04
  • Can you give me example on how to handle paging, sorting and filtering on the server side please. – EdwinP Oct 26 '15 at 06:21
  • update your question with Server Code. – Rakin Oct 26 '15 at 06:26
  • i already added the server code. thank you. – EdwinP Oct 26 '15 at 06:38

1 Answers1

1

I suppose that you have pure server side problem. You use WebMethod which returns JSON data. You can increase the limit by including something like jsonSerialization maxJsonLength="50000000"/> on the corresponding place in web.config. See the answer for more details.

I would recommend you additionally include loadError callback in jqGrid to see errors like "Error during serialization or deserialization using the JSON JavaScriptSerializer. he length of the string exceeds the value set on the maxJsonLength property." See the old answer for details of usage loadError callback.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • Actually I have previously include maxJasonLength in webconfig but does not work. also I have included this before returning the rows in "GetListFromDB" but dioes not work also. 'Dim instance As JavaScriptSerializer 'Dim value As Integer 'value = instance.MaxJsonLength 'Dim serializerB As New System.Web.Script.Serialization.JavaScriptSerializer() 'serializerB.MaxJsonLength = 2097152 'serializerB.Serialize(rows) – EdwinP Oct 26 '15 at 06:48
  • @EdwinP: What error you get? Do you included `loadError`? Do you tried to see the HTTP response from the server (using [Fiddler](http://www.telerik.com/fiddler) or Developer Tools of IE/Chrome)? – Oleg Oct 26 '15 at 07:20
  • I already include "loadError" and received HTTP message body (jqXHR.responseText): – EdwinP Oct 26 '15 at 14:39
  • {"Message":"Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.","StackTrace":" at System.Web.Script.Serialization.JavaScriptSerializer.Serialize(Object.... – EdwinP Oct 26 '15 at 14:40
  • And I already included serializerB.MaxJsonLength = Int32.MaxValue serializerB.Serialize(rows) in "GetListFromDB" method but still have the same error displayed. Hope you can help me Oleg. – EdwinP Oct 26 '15 at 14:41
  • @EdwinP: Sorry, but what I wrote you is **including the setting of new default value of `maxJsonLength` in `web.config`**. Your code use `Return rows`. So you return **the object which will be serialized by .NET itself**. So the call `serializer.Serialize(rows)` have no meaning. You don't save the results and .NET makes later for you *another serialization* and wrap the results in `{"d": ...}` (in `d` property of resulting object). Thus you get the same error like before. – Oleg Oct 26 '15 at 15:13
  • Thank you very much Oleg and Rakin, adjustment of value for maxJsonLength in web.config SOLVES my problem !!! – EdwinP Oct 27 '15 at 15:00