views:

34

answers:

1

Hi All, I am having a lot of trouble binding my Json data to a JqGrid.

In my Default.aspx.cs I have the following method :

[WebMethod]
        public static string GetData()
        {
            CustomerHelper C = new CustomerHelper();
            var data = C.GetAllCustomersSerialized();
            return data;

        }

The "C.GetAllCustomersSerialized();" method returns "return JsonConvert.SerializeObject(customersList);" from the CustomerHelper Class.

So basically I am returning serialized data as a string. Hope I am right till this point.

Now my Default.aspx is like so :

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">

    <script type="text/javascript">


        $(document).ready(function() {

            $("#Grid1").jqGrid(
        {
            url: "Default.aspx/GetData",
            data: "{}",
            type: "POST",
            dataType: "json",

            contentType: "application/json; charset=utf-8;",
            colNames: ['Customer Number', 'Customer Name'],
            colModel: [
                    { name: 'CUSNUM', index: 'CUSNUM', width: 80, align: 'left', jsonmap: 'CUSNUM' },
                    { name: 'CO_NAM', index: 'CO_NAM', width: 80, align: 'left', jsonmap: 'CO_NAM' }
                ],
            pager: $("#Pager1"),
            rowNum: 20,
            rowList: [10, 20, 30, 40, 50],
            sortname: 'cusnum',
            viewrecords: true,
            caption: 'Customers List'

        });
        });

    </script>
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">

    <table id="Grid1">
    </table>
    <div id="Pager1">
    </div>
</asp:Content>

I have a break point for the GetData() method in the code-behind but it is not being hit. All I get is an empty page with only the headers and the pagesize selection dropdown.

I lookedup all the different questions here which are similar to this, including http://stackoverflow.com/questions/2277962/jqgrid-and-dynamic-column-binding but it doesn't work for me.

Please help.

A: 

Well, its been a while and there was no headway made with jqGrid, so I dumped it and used JTemplates instead.

Sandeep