jqGrid, ASP.NET, JSON is Driving me crazy. Please Help

邮差的信 提交于 2019-11-29 07:47:14
  • 2
    You broke StackOverflow!!! – Mike Robinson Apr 7 '09 at 1:53
  • Opera users are advised to click on the "Fit to Width" button. :-) – staticsan Apr 7 '09 at 4:25
  • 1
    good luck! jqGrid needs some decent docs!! – wprl Jun 25 '09 at 20:12
1

Actually, tvanfosson makes an excellent point with the requirement of the 'rows' identifier. I'm unfamiliar with jMSAjax so my comments may be null and void. I'm glad to be aware of it.


Could it be something as simple as the return type being string? That is, when the response is evaluated, you end up with the encapsulated string not the json object.

I've been in a similar place myself. I found the options to be either, create a business object that represents the expected jqGrid response and return the object not a string (ASP.NET will serialize it as JSON for you!) or modify the jqGrid to eval the response twice (messy).

  • 1
    Yes! I definitely was missing "rows". Thanks! Unfortunately, I'm not quite out of the woods. FF is now giving me this error: missing ] after element list [Break on this error] ([object Object],[object Object],[object...Object],[object Object],[object Object]) – Briana Finney Apr 7 '09 at 4:06
  • Yes! I definitely was missing "rows". Thanks! Unfortunately, I'm not quite out of the woods. – Briana Finney Apr 7 '09 at 4:07
  • It's hard to say from the data that you have posted (I'm noticing some characters that may need to be escaped - htmlencode?). I think your best bet is to simplify the data as much as possible and see if you can get that to fly first. – Ajw Apr 7 '09 at 4:22
2

missing an identifier for that list:

return_value = {
    total:1,
    page:1,
    records:5,
    [{  .. some X12 messages  ..}]
}
    2

    I have spent a lot of time trying to get jqGrid to work with ASP.NET using JSON. Now that I have it working, I would like to share it with you. Hoping to save time for other people.

    I found the answer here. This is not to say there are no other ways to make this work (I'm sure there are). But this one definitely works.

    To summarize the things that made a difference for me:

    • Using "datatype: function() {" on the settings of the jqGrid, and NOT using "datatype: json". The function uses "$.ajax(" to call the service. Looking in Fiddler, this changed the data coming back to the browser, to be pure JSON (instead of JSON wrapped in XML).
    • Using a web service that returns a data class (in the schema jqGrid expects). I first tried using JSON.NET but for some reason the message showed (in Fiddler again) to be escaped with \ for every quote in the string. I'm pretty sure you can get JSON.NET to work. But it works just as well without it.
    • yes, but with datatype: function() solution, some other functionality starting to behave strange, like loadonce attribute for example..take a look at my question at scfl: stackoverflow.com/questions/1329002/… – Marko Aug 25 '09 at 15:29
    1

    It doesn't look like you are adding the rows property identifier. Try changing:

    json.Append(JsonConvert.SerializeObject(objPageCollection))
    

    to

    json.Append("rows: " + JsonConvert.SerializeObject(objPageCollection))
    

    If this doesn't work, I suggest that you simplify the problem -- reduce the data to one row, for example -- and see if you can get it working with simpler data, then gradually add more stuff back into it.

      Your Answer

      By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

      Not the answer you're looking for? Browse other questions tagged or ask your own question.

      易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
      该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!