0

I'm pulling my hair out trying to figure out why the JSON getting returned from my webMethod is working in firefox but not IE8.

So, I went to the basics just to see if I could even use the jqGrid in IE8 and it does render.

If I use static data such as:

using Newtonsoft.Json;

[WebMethod]
    public static string GetProjects()
    {
       
        string sql = "SELECT PMID, Title FROM DBO.[GET_PROJECTS]";
        SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
        DataSet ds = new DataSet();

        using (conn)
        {
            SqlDataAdapter da = new SqlDataAdapter(sql, conn);
            da.Fill(ds);
           
   return JsonConvert.SerializeObject(ds.Tables[0]);  //Convert this into a json string

        }

    }

When I use the WebMethod, the paginator show s up , the outline and column headers show up but the records do not and I can't figure out why. I'm sure it's a simple fix but I've been searching for a few days to get an example that works. Any that I download don't work in IE8.

So, below is my code, can anyone see any methods that I'm not doing correctly?

link href="JQGridReg/Styles/ui.jqgrid.css" rel="stylesheet" />
    <link href="JQGridReg/jquery-ui.css" rel="stylesheet" />
    <%--<script type="text/javascript" src="common/Scripts/jquery-1.11.0.min.js"></script>--%>
    <script type="text/javascript" src="common/Scripts/jquery-1.11.2.min.js"></script>
    <script type="text/javascript" src="JQGridReg/jquery.jqGrid.min.js"></script>
    
    <script type="text/javascript" src="JQGridReg/grid.locale-en.js"></script>

<script type="text/javascript">
     $(document).ready(function () {
$(document).ready(function () {
        //   $("#btnLoad").click(function(){
               $.ajax({
                   url: "PMProjectAdmin.aspx/GetProjects",  //webmethod
                   dataType: "json",                   
                   contentType: "application/json;charset=utf-8", //which type of content you want to post and retrieve from server
                   method: "POST",
                   success: function (result) {
                       alert(result.d);
                       result = result.d;
                       jQuery("#tblPMs").jqGrid({
                           datatype: "local",
                           colNames: ["PMID", "Title"],
                           colModel: [
                               { name: "PMID", index: "PMID", width: 20, align: "center", sortable: true },
                               { name: "Title", index: "Title", width: 200 }
                           ],
                           data: JSON.parse(result), //Load Data
                           rowNum: 10, //Total records to show at a time by default
                           loadonce: true,
                           rowList: [5, 10, 20], //for paging
                           pager: "#divPMPager",
                           viewrecords: true,
                           sortorder: "asc",
                           gridview: true,
                           autowidth: true,
                           sortname: "PMID",
                           height: "auto",
                           altRows: true,
                           hoverrows: true,
                           caption: " Projects"
                       });
                   },
                   error: function (msg) { alert("Error: " + msg.responseText); }///error
           });
       });
       </script>

Web Method:

using Newtonsoft.Json;

[WebMethod]
    public static string GetProjects()
    {
       
        string sql = "SELECT PMID, Title FROM DBO.[GET_PROJECTS]";
        SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
        DataSet ds = new DataSet();

        using (conn)
        {
            SqlDataAdapter da = new SqlDataAdapter(sql, conn);
            da.Fill(ds);
           
   return JsonConvert.SerializeObject(ds.Tables[0]);  //Convert this into a json string

        }

    }

When the alert pops up, this is the JSON string. I've even tried hard coding it in the webmethod:

"[{\"PMID\":48,\"Title\":\"****\"},{\"PMID\":83,\"Title\":\"Title #2\"},{\"PMID\":61,\"Title\":\"Title #3\"}]"

EDIT

(Moved comment)

Thank you @tony_tomov. I'm not currently not including the jquery.jqGrid.src.js. So, I added it:

    <link href="JQGridReg/Styles/ui.jqgrid.css" rel="stylesheet" />
    <link href="JQGridReg/jquery-ui.css" rel="stylesheet" />
     <script type="text/javascript"  src="common/Scripts/jquery-1.11.2.min.js"></script>
    <script  type="text/javascript" src="JQGridReg/jquery.jqGrid.min.js"></script>
    <script type="text/javascript" src="JQGridReg/jquery.jqGrid.src.js"></script>
    <script  type="text/javascript" src="JQGridReg/grid.locale-en.js"></script>
    
   <script type="text/javascript" src="common/Scripts/json3.min.js"></script>

I want to make this looks correct. I verified that I'm using the 4.7 files and updated the src.js. but I'm still getting a loading error.

Is there a simple solution or a link that I can download as a base which would work in IE?

Stphane
  • 3,368
  • 5
  • 32
  • 47
  • I can confirm the bug. See the solution {here](http://stackoverflow.com/a/28220611/315935) – Oleg Feb 05 '15 at 06:12

1 Answers1

0

This is a bug when trying to make better performance in the 4.7 version. It is fixed. It will be available soon in the upcoming 4.8 release

Tony Tomov
  • 3,122
  • 1
  • 11
  • 18