Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
300
jQuery igGrid databind no data appears
posted

I am having some issues with getting data to display using the igGrid.  I am programming in asp.net and calling a webmethod that returns json object back to the javascript.

Here is my code.

function test_json() {
    simpleLoad('orderdetail.aspx/GetOrderTotal', { orderid: '40069' }, testjson_success);
    return false;
}

my webmethod

Public Shared Function GetOrderDetail(ByVal PostData)
        Dim outputObj As New Dictionary(Of String, String)

        Dim _orderLines As EmunWorks.Info.SalesOrderLinesTotalInfo()
        Dim _orderLinesDB As New EmunWorks.DataAccess.SalesOrderLinesDB
        _orderLines = _orderLinesDB.GetSalesOrderLineTotals("40069")

        Dim jsSerializer As System.Web.Script.Serialization.JavaScriptSerializer
        jsSerializer = New System.Web.Script.Serialization.JavaScriptSerializer()

        Dim sbOrder As New System.Text.StringBuilder()

        jsSerializer.Serialize(_orderLines(0), sbOrder)

        Dim json As String = sbOrder.ToString()
        Return json
    End Function

if data get is successful then this
function testjson_success(data) {

    $("#grid1").igGrid({
        autoGenerateColumns: false,
         columns: [
            { headerText: "Line Count", key: "lineCount", dataType: "number" },
            { headerText: "Qty Count", key: "qtyCount", dataType: "numbers" }
        ],
        dataSource: data,
        width: '500px'
    });

}

the data object returns this json response.

{"d":{"lineCount":"23","qtyCount":"56","extendedSum":"$5,000.16"}}

I have also tried this response, but no luck

"{"LineCount":23,"QtyCount":56,"ExtendedSum":5000.1600000000008}"

my web method is really a an object that i Serialize to json

object.LineCount

object.QtyCount

Any help would be greatly appreciated.

Sy

Parents
  • 24671
    posted

    hi,

    your response should be an array, not object. i mean, it should be something like:

    "[ {"LineCount":23,"QtyCount":56,"ExtendedSum":5000.1600000000008} ] "

    (that's assuming you have one record). In order for that to work, you can change your webmethod to be like this:

            jsSerializer.Serialize(_orderLines, sbOrder)

    Notice i have changed _orderLines(0) to just _orderLines.

    Hope that helps. If you keep with the first format, that includes "d" as the root path, you need to set responseDataKey: "d", so that the grid can find where your records are located in the response. You can also have a look at the online API docs:

    http://help.infragistics.com/jQuery/2011.1/ui.iggrid#!options

    Thanks

    Angel

Reply Children