{"id":1960,"date":"2022-08-30T15:20:53","date_gmt":"2022-08-30T15:20:53","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/12\/05\/cannot-toggle-checkboxes-on-grid-with-a-selectall-checkbox-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:20:53","modified_gmt":"2022-08-30T15:20:53","slug":"cannot-toggle-checkboxes-on-grid-with-a-selectall-checkbox-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/cannot-toggle-checkboxes-on-grid-with-a-selectall-checkbox-collection-of-common-programming-errors\/","title":{"rendered":"Cannot toggle checkboxes on grid with a selectall checkbox-Collection of common programming errors"},"content":{"rendered":"<p>I want to be able to select\/unselect checkboxes for a specific column in a grid.<\/p>\n<p>It gets an error inside the JS &#8220;onUPCSelectAll&#8221; function on the eval statement as follows: <strong>JS runtime error: Object doesn&#8217;t support property or method &#8216;SetChecked&#8217;<\/strong><\/p>\n<p>During debugging, I am able to see that my id value is:<\/p>\n<pre><code>$(this)[0].id = \"PrintCallbackPanel_selectAllUPCCheckBox\"\n<\/code><\/pre>\n<p>My source code does indeed have this particular id set up, but, you can see where the id value actually places an &#8220;_S&#8221; onto the end of the control name.<\/p>\n<p>Select\/Unselect all UPC rows<\/p>\n<p>The &#8220;SetChecked&#8221; method produces the following:<\/p>\n<pre><code>eval($(this)[0].id).SetChecked = function(isChecked) {\n  this.SetCheckState(isChecked ? ASPxClientCheckBoxCheckState.Checked : ASPxClientCheckBoxCheckState.Unchecked);\n }\n<\/code><\/pre>\n<p>and finally, the full line produces an undefined value<\/p>\n<pre><code>?eval($(this)[0].id).SetChecked(s.GetChecked());\nundefined\n<\/code><\/pre>\n<p><strong>HTML:<\/strong><\/p>\n<td style=\"padding-right: 10px;\"><\/td>\n<td style=\"padding-right: 10px;\"><\/td>\n<p><strong>HTML Grid:<\/strong><\/p>\n<pre><code>\n        \n        \n            \n                \n                    \n                    \n                \n                <\/code><\/pre>\n<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\n<tr>\n<td class=\"auto-style2\">\n<table cellpadding=\"0\" cellspacing=\"0\" id=\"searchTable\" runat=\"Server\">\n<tr>\n<td style=\"padding-right: 10px;\"><\/td>\n<td style=\"padding-right: 10px;\"><\/td>\n<td style=\"padding-right: 10px;\"><\/td>\n<td style=\"padding-right: 10px;\"><\/td>\n<td style=\"padding-right: 10px;\"><\/td>\n<td class=\"auto-style3\"><\/td>\n<\/tr>\n<tr>\n<td colspan=\"6\" style=\"height: 5px;\"><\/td>\n<\/tr>\n<\/table>\n<\/td>\n<\/tr>\n<\/table>\n<table cellpadding=\"0\" cellspacing=\"0\" runat=\"server\" id=\"selectionTable\">\n<tr>\n<td style=\"padding-right: 10px;\" class=\"auto-style4\"><\/td>\n<td style=\"padding-right: 10px;\"><\/td>\n<td style=\"padding-right: 10px;\"><\/td>\n<td style=\"padding-right: 10px;\"><\/td>\n<td style=\"padding-right: 10px;\"><\/td>\n<\/tr>\n<tr>\n<td colspan=\"6\" style=\"height: 5px;\"><\/td>\n<\/tr>\n<\/table>\n<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\n<tr>\n<td><\/td>\n<\/tr>\n<\/table>\n<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\n<tr>\n<td style=\"padding: 5px;\"><\/td>\n<\/tr>\n<tr>\n<td align=\"right\"><\/td>\n<\/tr>\n<\/table>\n<p><strong>JS:<\/strong><\/p>\n<pre><code>function onUPCSelectAll(s, e) {\n    $('[id*=\"selectAllUPCCheckBox\"]').each(function () {\n        eval($(this)[0].id).SetChecked(s.GetChecked());\n    });\n};\n\nfunction onMPCSelectAll(s, e) {\n    $('[id*=\"selectAllMPCCheckBox\"]').each(function () {\n        eval($(this)[0].id).SetChecked(s.GetChecked());\n    });\n};\n<\/code><\/pre>\n<ol>\n<li>\n<p>You select all checkboxes&#8217; Ids start with lower case <code>s<\/code> and you&#8217;re using a capital <code>S<\/code> in the jQuery selector.<\/p>\n<p>Change the code to:<\/p>\n<pre><code>function onUPCSelectAll(s, e) {\n             $('[id*=\"selectAllUPCCheckBox\"]').each(function () {\n                 eval($(this)[0].id).SetChecked(s.GetChecked());\n             });\n         };\n\n         function onMPCSelectAll(s, e) {\n             $('[id*=\"selectAllMPCCheckBox\"]').each(function () {\n                 eval($(this)[0].id).SetChecked(s.GetChecked());\n             });\n         };\n<\/code><\/pre>\n<p>The selector is case sensitive.<\/p>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2013-12-05 16:32:08. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I want to be able to select\/unselect checkboxes for a specific column in a grid. It gets an error inside the JS &#8220;onUPCSelectAll&#8221; function on the eval statement as follows: JS runtime error: Object doesn&#8217;t support property or method &#8216;SetChecked&#8217; During debugging, I am able to see that my id value is: $(this)[0].id = &#8220;PrintCallbackPanel_selectAllUPCCheckBox&#8221; [&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-1960","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1960","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=1960"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1960\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1960"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1960"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1960"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}