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 thisfunction 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
I am using same code snippet but I am not able to display the data, only header is being shown up on UI. Please suggest me.
Angel thank you so much that fixed it.
Please have a look at the attached screenshot. You don't have "d" property in the response. So it should be just data. Or if you have the format where your records are stored in "d", then it's data.d.
Thanks,
Angel
Still no luck using that. You can try it yourself here http://emunportal.com:3500/deploy/ewonline/jsontest.aspx
i know it is something with the data source, because I can set it up manually and it will work.
thanks
sy
Ok i see,
i haven't realized you are actually not having the URL as the data source but directly supplying your local javascript object. In that case you can just set dataSource: data.d, and responseDataKey is not necessary.
Hope it helps,