{"id":6325,"date":"2014-04-15T19:46:40","date_gmt":"2014-04-15T19:46:40","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/04\/15\/jqgrid-filter-toolbar-colmodel-object-is-null-or-undefined-problem-collection-of-common-programming-errors\/"},"modified":"2014-04-15T19:46:40","modified_gmt":"2014-04-15T19:46:40","slug":"jqgrid-filter-toolbar-colmodel-object-is-null-or-undefined-problem-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/04\/15\/jqgrid-filter-toolbar-colmodel-object-is-null-or-undefined-problem-collection-of-common-programming-errors\/","title":{"rendered":"jqGrid Filter Toolbar &#8211; colModel: object is null or undefined problem-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/c132bc0f7940bbe669ea64267fd84c47?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nHorst Walter<\/p>\n<p>Actually creating a filter <strong>jqGrid toolbar<\/strong> should be straight ahead as in the &#8220;new in 3.5, integrated search toolbar&#8221; example or documentation.<\/p>\n<p>However, when I run the line <code>myDataTable.jqGrid('filterToolbar', filterOpts);<\/code> I always get an error &#8220;Unable to get value of the property &#8216;colModel&#8217;: object is null or undefined&#8221; in line 3613 of JQuery.jqGrid.src.js, which is: <code>$.each($t.p.colModel,function(i,n) { ..<\/code><\/p>\n<p>Just for the record, version of jqGrid is 4.1.2. The grid itself display \/ works OK.<\/p>\n<p>Here is the code how I init the grid, most likely I do oversee something very simple.<\/p>\n<pre><code>    var ft = document.getElementById(\"myData\"); \/\/ this is the HTML table element as usual\n    var colModel = [\n    { name: 'i', index: 'i', width: 60, hidden: true, search: false },\n    { name: 'c', index: 'c', width: 100, search: true },\n    { name: 'p', index: 'p', width: 100, search: true },\n    { name: 'displayed', index: 'displayed', align: 'center', width: 100, formatter: booleanToCheckmark, search: false },\n];\n    $(function() {\n        $(ft).jqGrid({\n                datatype: 'clientSide',\n                data: globals.myData, \/\/ Array of objects (\"the data\"), data is correctly displayed\n                height: 300,\n                \/\/ autowidth: true,\n                width: 300,\n                forceFit: true,\n                colNames: ['I', 'C', 'P', 'dis.'],\n                colModel: colModel,\n                rowNum: 10000,\n                sortname: 'displayed',\n                sortorder: 'desc',\n                viewrecords: true,\n                gridview: true,\n                caption: 'XYZ'\n            });\n    });\n    \/\/ filter bar\n    \/\/ http:\/\/www.trirand.com\/jqgridwiki\/doku.php?id=wiki:toolbar_searching\n    var filterOpts = { autosearch: true };\n\n    \/\/ LINE WHERE IT FAILS\n    $(ft).jqGrid('filterToolbar', filterOpts);\n<\/code><\/pre>\n<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/d2fe88fb2ca8a2047771bde11d39814c?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nOleg<\/p>\n<p>The error that you try to call <code>filterToolbar<\/code> <strong>outside<\/strong> of <code>$(function() {\/*it should be called here*\/});<\/code> block.<\/p>\n<p>Typically one places <strong>all<\/strong> the code inside of <code>$(function() {...});<\/code>. In the way one reduces additionally the number of global variables which will be added as the properties to <code>window<\/code>. The usage of global variables increase additionally the probability to have conflicts with other standard global variables.<\/p>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Horst Walter Actually creating a filter jqGrid toolbar should be straight ahead as in the &#8220;new in 3.5, integrated search toolbar&#8221; example or documentation. However, when I run the line myDataTable.jqGrid(&#8216;filterToolbar&#8217;, filterOpts); I always get an error &#8220;Unable to get value of the property &#8216;colModel&#8217;: object is null or undefined&#8221; in line 3613 of JQuery.jqGrid.src.js, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-6325","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6325","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=6325"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6325\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=6325"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=6325"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=6325"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}