0

Using jqGrid 4.7.1, jquery 1.9.1 & jquery-ui 1.10.4 in Visual Studio Express 2012 for Web and publishing a page as a default website on my localhost. IIS version is 7.5. The package loads XML from a static file into a grid that can be searched.

I am able to debug the page in VS Express 2012 for Web in any browser without errors. When I publish it, it is deployed in IIS via right-clicking on the Default Web Site --> Deploy --> Import Application. The defaults are taken when the package is deployed. Since I'm installing over an existing application, the option "No, just append the files in the application package to the destination." is selected. The package deploys successfully, and IIS is re-started.

Using current versions of Chrome & Firefox without an issue. The site works fine & the grid loads without issue in IE11 when accessed via the URL http://localhost/myWebSite. However, I get the following error in IE only when accessing the site via the machine name URL: http://mymachine/myWebSite

The error produced is: SCRIPT5007: Unable to get property 'innerHTML' of undefined or null reference. File: jquery.jqGrid.min.js, Line: 64, Column: 205

The error is produced when the grid is being loaded. I show the grid header, footer and column headings, and the "Loading" message when the error is produced. The grid functions perfectly using other browsers using either the localhost or machine name URL. It can be accessed by other users using the http://mymachine/myWebSite URL as long as they are not on IE10 or IE11 (I am unable to test other versions of IE).

I am reasonably sure that the jqGrid is set up properly. The colModel contains name, xmlmap, & width on all columns, except for 3. Two of those have an index, sorttype, formatter, formatoptions in them, and the third has a custom formatter in it (hyperlink to a pdf).

Any idea as to what the problem could be, or a way to fix it? Any input would be appreciated.

EDIT

I changed it to use the jquery.jqGrid.src.js script and ran it on Firefox & Chrome with no issues. IE though produces the same SCRIPT5007 error. It is at line 1447, column 6, which is on this line of code:

ts.firstElementChild.innerHTML += rowData.join(''); // append to innerHTML of tbody which contains the first row (.jqgfirstrow)

My jqGrid code, which is pretty plain:

 var createGrid = function () {
     $("#myGrid").jqGrid({
         url: "mydata.xml",
         xmlReader: {
  repeatitems: false,
  root: "Recordset",
  row: "Record",
  id: "[setEntry]"
         },
         dataType: "xml",
         colNames: [
  "Product",
  "Manufacturer",
  "Date Created",
  "Date Modified",
  "Image Link",
         ],
         colModel: [
  { name: "PROD_NAME", xmlmap: "Recordset>Record>PROD_NAME" },
  { name: "MFR", xmlmap: "Recordset>Record>MFR", width:175 },
  { name: "DATE_CREATED", xmlmap: "Recordset>Record>DATE_CREATED", width:125, index: "DATE_CREATED", sorttype:"date", formatter: "date", formatoptions: {srcformat:"F d, Y H:i:s", newformat:"Y-m-d H:i:s"}, datefmt:"Y-m-d H:i:s" },
  { name: "DATE_MODIFIED", xmlmap: "Recordset>Record>DATE_MODIFIED", width:125, index: "DATE_MODIFIED", sorttype: "date", formatter: "date", formatoptions: { srcformat: "F d, Y H:i:s", newformat: "Y-m-d H:i:s" }, datefmt: "Y-m-d H:i:s" },
  {
      name: "IMAGE", xmlmap: "Recordset>Record>IMAGE", width:100,
      formatter: function (cellValue, options, rowObject) {
         return '<a href="../Work_Documents/' + cellValue + '" target="_blank" >' + cellValue + '</a>';
    }
  }
         ],
         rowNum: 10,
         pager: jQuery("#pager1"),
         gridview: true,
         rownumbers: false,
         height: "auto",
         loadonce: true,
         autoencode: true,
         caption: "MyGrid",
         ignoreCase: true, // default is case-sensitive, this makes it case-insensitive
         hidegrid: false,
         altrows: true,
         recordtext: "View {0} - {1} of {2}",
         emptyrecords: "No Records to View",
         pgtext: "Page {0} of {1}"
     }).navGrid("#pager1", { edit: false, add: false, del: false}, {},{},{}, {multipleSearch: true, multipleGroup: true}, {searchtext: "Search" });
 };

The structure of the data is below. The attribute setEntry is a unique number in the XML file.

<Recordset>
   <Record setEntry="1">
      <PROD_NAME>MyProduct</PROD_NAME>
      <MFR>ABC D and Company</MFR>
      <DATE_CREATED>September 30, 2014 14:41:36</DATE_CREATED>
      <DATE_MODIFIED>September 30, 2014 14:50:55</DATE_MODIFIED>
      <IMAGE>abcd.pdf</IMAGE>
   </Record>
</Recordset>   

Again, the error does NOT occur when using the http://localhost/myWebSite URL, it only occurs when I use the http://mymachine/myWebSite URL. And, it occurs in IE only - Firefox & Chrome have no problems with the code, regardless of the URL used.

EDIT #2

I found a workaround here.

The change was made in my Site.Master file, changing the meta tag in it. It had been this:

<head runat="server">
   <meta charset="utf-8" />

and I changed it to:

<head runat="server">
    <meta charset="utf-8" http-equiv="X-UA-Compatible" content="IE=edge" />

which seems to run the http://mymachine/myWebSite URL in IE without the error occurring, and does not seem to cause other issues.

This is just a workaround, not necessarily a solution.

EDIT 3

@Oleg - here is the code using the free 4.7 version found in the jquery-master zip file at the link.

 var createGrid = function () {
     $("#myGrid").jqGrid({
         url: "mydata.xml",
         xmlReader: {
  repeatitems: false,
  root: "Recordset",
  row: "Record",
  id: "[setEntry]"
         },
         datatype: "xml",
         colNames: [
  "Product",
  "Manufacturer",
  "Date Created",
  "Date Modified",
  "Image Link",
         ],
         colModel: [
  { name: "PROD_NAME", xmlmap: "Recordset>Record>PROD_NAME" },
  { name: "MFR", xmlmap: "Recordset>Record>MFR", width:175 },
  { name: "DATE_CREATED", xmlmap: "Recordset>Record>DATE_CREATED", width:125, index: "DATE_CREATED", sorttype:"date", formatter: "date", formatoptions: {srcformat:"F d, Y H:i:s", newformat:"Y-m-d H:i:s"}, datefmt:"Y-m-d H:i:s" },
  { name: "DATE_MODIFIED", xmlmap: "Recordset>Record>DATE_MODIFIED", width:125, index: "DATE_MODIFIED", sorttype: "date", formatter: "date", formatoptions: { srcformat: "F d, Y H:i:s", newformat: "Y-m-d H:i:s" }, datefmt: "Y-m-d H:i:s" },
  {
      name: "IMAGE", xmlmap: "Recordset>Record>IMAGE", width:100,
      formatter: function (cellValue, options, rowObject) {
         return '<a href="../Work_Documents/' + cellValue + '" target="_blank" >' + cellValue + '</a>';
    }
  }
         ],
         rowNum: 10,
         pager: true,
         gridview: true,
         rownumbers: false,
         height: "auto",
         loadonce: true,
         autoencode: true,
         caption: "MyGrid",
         ignoreCase: true, 
         hidegrid: false,
         altrows: true,
         recordtext: "View {0} - {1} of {2}",
         emptyrecords: "No Records to View",
         pgtext: "Page {0} of {1}",
         navOptions: {
              edit: false,
              add: false,
              del: false,
              searchtext: "Search"
              },
         searching: {
              multipleSearch: true,
              multipleGroup: true
              }
     }).navGrid();
 };

The HTML portion of the page is now:

<div id="UpdatePanel" style ="padding:20px 10px">
    <table id="myGrid" border="0" cellpadding="0" cellspacing="0" style="width:100%">
        <tr>
            <td></td>
        </tr>
    </table>        
</div>

All of the links & scripts:

<link href="Scripts/jquery-ui-1.10.4.custom/css/cupertino/jquery-ui.css" rel="stylesheet" type="text/css" />
<link href="Scripts/jqGrid-master/css/ui.jqgrid.css" rel="stylesheet" type="text/css"/>
<script src="Scripts/jquery-1.9.1.js" type="text/javascript"></script>
<script src="Scripts/jquery-ui-1.10.4.custom/js/jquery-ui-1.10.4.custom.js" type="text/javascript"></script>
<script src="Scripts/jqGrid-master/js/i18n/grid.locale-en.js" type="text/javascript"></script>
<script src="Scripts/jqGrid-master/js/jquery.jqGrid.src.js" type="text/javascript"></script>
<link href="CustomFormatter.css" rel="stylesheet" type="text/css"/>

The above configuration will load the grid without any problem. However, when the Search button is clicked, an error occurs in jquery-1.9.1.js on line 622 column 3. The statement is length = obj.length, and the error is TypeError: obj is undefined.

Community
  • 1
  • 1
steve_o
  • 1,243
  • 6
  • 34
  • 60
  • If you post error report you should always use `jquery.jqGrid.src.js` instead of `jquery.jqGrid.min.js` and post the line number of the error in the file. You should all your code in the text of the question. By the way, do you use `getCol` method of jqGrid in your code? Which values for the first parameter you use (names or column numbers)? – Oleg Feb 20 '15 at 17:12
  • @Oleg - see edits made above for example of grid code, data and resulting error (same as before, but on a different line). – steve_o Feb 20 '15 at 19:26
  • I posted my answer (see below). I would recommend you additionally to consider to change format of input data from XML to JSON (of cause only if your component generates the data). jQuery and jqGrid contains very restricted and relatively slow possibility to parse XML data. So the usage of JSON will provide only advantages. By the way the option `dataType: "xml"` will be ignored (because it has wrong name) and the default `datatype: "xml"` option will be used by jqGrid. – Oleg Feb 20 '15 at 19:58
  • @Oleg - thank you for spotting my error & correcting me. I've made that code change. I wish I could use JSON, but unfortunately XML is the only option available to me as a data source. – steve_o Feb 20 '15 at 20:55

2 Answers2

2

It seems that you made the tests on IE in different versions. IE10-IE11 should have no problems with the usage of ts.firstElementChild.innerHTML, but old versions of IE don't support firstElementChild property. You should follow the answer or this one. You can download the fixed version of jqGrid 4.7 from here or to download new beta version of new free jqGrid version from my fork here. I plan to publish new version of jqGrid very soon.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • I did test on both IE10 & IE 11. In reading your fix, I was confused about the versions. I downloaded 4.7.1 from Tony's site, and I see your version is based on 4.7.0. I compared the code from both, and your fix is not in the 4.7.1 version. I counted 5 places where there were code differences, 4 of which were not (yet) in your version. When are you targeting your release? – steve_o Feb 20 '15 at 20:47
  • @steve_o: during every change of the main code I generate `jquery.jqGrid.src.js`, `jquery.jqGrid.min.js` and `jquery.jqGrid.min.map` files too. So you can download *the current state of free jqGrid* from [here](https://github.com/free-jqgrid/jqGrid/archive/master.zip) and just use the files together with locale file `grid.locale-XX.js` which you need. By the way version 4.7.1 is almost identical to 4.7, but 4.7 is for free and one need to pay for 4.7.1 (see prices for [Guriddo jqGrid JS](http://guriddo.net/?page_id=103334)) – Oleg Feb 20 '15 at 20:58
  • Thank you for the clarification. And, as always, thank you for the help. – steve_o Feb 20 '15 at 21:36
  • I downloaded the free jqGrid & replaced the 4.71 version in my code, but get the error **jqGrid is not a function** when I click on a button to load the grid. The code I use for that is `$("btnGetData").click(function() { $("myGrid").jqGrid('GridUnload'); createMyGrid(); });` which creates the grid above. I have 2 buttons, each loading a separate data source into essentially the same grid. The above code used to unload a grid & load the specific grid. I've checked to make sure the usual things (grid.locale-en.js & jquery.jqGrid.js) are referenced properly. Ideas? – steve_o Feb 23 '15 at 13:41
  • Just FYI - I have **not** downloaded & installed the _fixed_ version of free jqGrid - I was trying to get it to simply load using the **jqGrid-master** file from the archive link in your post. – steve_o Feb 23 '15 at 13:50
  • @steve_o: You should use **`jquery.jqGrid.src.js` or `jquery.jqGrid.min.js` instead of `jquery.jqGrid.js`** (see [the documentation](http://www.trirand.com/jqgridwiki/doku.php?id=wiki:first_grid#html_file`)). If you use English US locale then `grid.locale-en.js` is optional for free jqGrid. The (free-jqGrid)[https://github.com/free-jqgrid/jqGrid/archive/master.zip] downloaded from github have `jquery.jqGrid.src.js`, `jquery.jqGrid.min.js` and `jquery.jqGrid.min.map` in `jqGrid-master\js` folder. The folder `jqGrid-master\js\i18n` contains local files. – Oleg Feb 23 '15 at 15:03
  • Thank you - I've got the correct js file referenced now. Did something change with the `navGrid` options? Once I got the grid to display, I noticed that the search options no longer displayed in the grid's footer. – steve_o Feb 23 '15 at 16:45
  • @steve_o: You are welcome! What is not longer displayed? The code which you posted contains the error: you use `.navGrid("#pager1", { edit: false, add: false, del: false}, {},{},{}, {multipleSearch: true, multipleGroup: true}, {searchtext: "Search" });` where `{searchtext: "Search" }` is the option of **View**. You mean probably `.navGrid("#pager1", { edit: false, add: false, del: false, searchtext: "Search"}, {},{},{}, {multipleSearch: true, multipleGroup: true});`? I made many changes in `navGrid` but all is upwards compatible. – Oleg Feb 23 '15 at 16:58
  • @steve_o: As the new feature you can use *skip* `"#pager1"` parameter in `navGrid`. Additionally you can move searching options of navGrid to the option of jqGrid. In the same way one can move the main `navGrid` options to jqGrid too. You can try to add `navOptions: {edit: false, add: false, del: false, searchtext: "Search"}, searching: {multipleSearch: true, multipleGroup: true}` as additional **option of jqGrid** and then call `navGrid` **without parameters**: `.navGrid();` You can remove `
    ` from the HTML page and use `pager: true` instead of `pager: jQuery("#pager1")`
    – Oleg Feb 23 '15 at 17:08
  • 1
    I put in your code as you have it above verbatim; however, jQuery-1.9.1.js gives an error (line 622, col 3) `length = obj.length,` when I click on the Search link. I tacked the code in your message above at the end of the `pgtext` option & also changed the `pager` option to true, and removed the `
    ` from the page as well. Am I missing an additional setting?
    – steve_o Feb 23 '15 at 18:23
  • @steve_o: Could you post the demo or the code which you use currently. [The line 622](https://github.com/free-jqgrid/jqGrid/blob/master/js/grid.base.js#L622) don't contains any `length = obj.length`. Do you use now something other as `jquery.jqGrid.src.js`? You should never use `jquery.jqGrid.min.js` till you have working code. In any way the `jquery.jqGrid.min.js` of my current jqGrid contains only 587 rows. – Oleg Feb 23 '15 at 18:28
  • @steve_o: OK, I've found the bug. Thank you! It was because I didn't tested all cases after implementing [the feature](https://github.com/free-jqgrid/jqGrid/wiki/Custom-filtering-searching-Operation). I uploaded the fixed version on [github](https://github.com/free-jqgrid/jqGrid). Please reload the code. Try at [the demo](http://www.ok-soft-gmbh.com/jqGrid/OK/autoresizeOnDoubleClickOnColumnResizer.htm) for example or [this one](http://www.ok-soft-gmbh.com/jqGrid/OK/navButtons0-fa4.htm). – Oleg Feb 23 '15 at 18:40
  • I grabbed the new version, but am still getting the error from **jquery-1.9.1.js**. – steve_o Feb 24 '15 at 14:34
  • Do you use `` on the page like it described in [the documentation](http://www.trirand.com/jqgridwiki/doku.php?id=wiki:first_grid#html_file). I'm sure that the problem can be solved in minutes if you would provide the demo which reproduces the problem. Moreover please include **always** the line number in jqGrid where the problem occur. You need just start Developer Tools (press F12), click on "Script" and "Start debugging". On error you will be able to see in "Call Stack" the place or error in `jquery.jqGrid.src.js`. – Oleg Feb 24 '15 at 14:45
  • I had commented that out of the Site.master page & put it back in, it seemed to work. The search in IE worked okay. Chrome also. I noticed in Firefox though, that the Search & Reload icons do not appear. The `
    ` is there (search_myGrid, refresh_myGrid), but empty. The `SPAN` in FF is ``, while the `SPAN` in Chrome & IE is `` Must be something FF doesn't like, but 4.7.1 version displayed the icons in all. Also - is there a way to change the pager to re-position the page controls?
    – steve_o Feb 24 '15 at 16:22
  • @steve_o: I'm not sure which version of jqGrid you use. I recommend you to download the current code [here](https://github.com/free-jqgrid/jqGrid) If you want to use Font Awesome then you should include `iconSet: "fontAwesome"` option to jqGrid and don't forget to include the fonts itself: ``. It was short time the version where I changed default value of `iconSet` from `"jQueryUI"` to `"fontAwesome"`, but I changed it back because I realized that not all people include the fonts. :-( – Oleg Feb 24 '15 at 16:35
  • I re-downloaded the jqGrid-master zip file & reloaded it. After clearing the cache in FF - several times - the icons finally appeared. I am looking forward to trying Font Awesome - the grids using them in your demos look amazing! Thank you again for your help! – steve_o Feb 24 '15 at 17:01
  • @steve_o: You are welcome! I prepare now publishing of new version of jqGrid and try to fix only the bugs which can be found. I create more detailed documentation of new features on [the wiki](https://github.com/free-jqgrid/jqGrid/wiki). I hope to publish the release 4.8 of free jqGrid this week or in the next week. Any feedback, bug reports and suggestions are welcome! – Oleg Feb 24 '15 at 17:07
0

Perhaps is something about your Security Zones in IE. Go to Tools -> Internet Options; then to Security tab. Check http://mymachine is in the same zone localhost is.

You can also try to add http://mymachine to Trusted sites.

Finally for me also worked sometime to add about: to the Trusted Sites zone

alphamikevictor
  • 595
  • 7
  • 17
  • Those settings are locked down for me. FWIW, http://mymachine is not in the Trusted Sites list. – steve_o Feb 20 '15 at 19:29