{"id":2239,"date":"2020-05-09T17:51:01","date_gmt":"2020-05-09T22:51:01","guid":{"rendered":"https:\/\/xlinesoft.com\/blog\/?p=2239"},"modified":"2020-05-09T17:57:17","modified_gmt":"2020-05-09T22:57:17","slug":"hiding-details-table-tab-on-the-fly","status":"publish","type":"post","link":"https:\/\/xlinesoft.com\/blog\/2020\/05\/09\/hiding-details-table-tab-on-the-fly\/","title":{"rendered":"Hiding details table tab on the fly"},"content":{"rendered":"<p>Master-details is a very useful feature but the details table may clutter the UI. We have seen projects where people have more than a dozen details tables and it would be useful if we can hide some that are not relevant to the current master table record. <\/p>\n<p>Let us take a look at this completely artificial example. A typical setup with Orders table as a master and Order Details, Employees, and Customers as details. We would like to hide the Employees table tab when OrderID is more than 10300. <\/p>\n<p><a href=\"https:\/\/xlinesoft.com\/blog\/wp-content\/uploads\/2020\/05\/scr_hide_details.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/xlinesoft.com\/blog\/wp-content\/uploads\/2020\/05\/scr_hide_details-300x276.png\" alt=\"\" width=\"300\" height=\"276\" class=\"alignnone size-medium wp-image-2241\" srcset=\"https:\/\/xlinesoft.com\/blog\/wp-content\/uploads\/2020\/05\/scr_hide_details-300x276.png 300w, https:\/\/xlinesoft.com\/blog\/wp-content\/uploads\/2020\/05\/scr_hide_details-768x708.png 768w, https:\/\/xlinesoft.com\/blog\/wp-content\/uploads\/2020\/05\/scr_hide_details.png 880w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\n<!--more--><\/p>\n<pre name=\"code\" class=\"js:nocontrols\">\r\n$(\"[id^=details_]\").bind(\"click\", function(){\r\n\r\n        \/\/ get ID of the current master table record   \r\n\tvar id = $(this).attr(\"data-record-id\"), res = false;\r\n\r\n        \/\/ loop through all master table records on the page\r\n\tvar allRecords = pageObj.getAllRecords();\r\n\trem = false;\r\n\t$.each(allRecords, function(i, row){\r\n\r\n        \/\/ If we found our record and value of OrderID is more than 10300\r\n        \/\/ than we will remove the tab. This is where you can add your own condition\r\n        if(row.recordId()== id && row.getFieldText(\"OrderID\")>\"10300\")\r\n            rem = true;\r\n    });\r\n        \/\/ actually removing the tab, 1 means second tab, 0 means first tab etc \r\n\tif(rem) {\r\n\t\t$(\"#tabs-details_details_preview\"+id).find(\"[data-tabidx=1]\").remove();\r\n\t\r\n  \t        \/\/ uncomment the following line if you need to hide the first tab\r\n\t\t\/\/ $(\"#tabs-details_details_preview\"+id\").find(\"[data-tabidx=1]\").find(\"a\").click();\r\n        }\r\n\r\n});\r\n<\/pre>\n<p>This is pretty much it. This code will work in version 10.x or better of PHPRunenr, ASPRunner.NET and ASPRunnerPro. Enjoy!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Master-details is a very useful feature but the details table may clutter the UI. We have seen projects where people have more than a dozen details tables and it would be useful if we can hide some that are not relevant to the current master table record. Let us take a look at this completely artificial example. A typical setup with Orders table as a master and Order Details, Employees, and Customers as details. We would like to hide the Employees table tab when OrderID&#8230;<span class=\"clearfix clearfix-post\"><\/span><a href=\"https:\/\/xlinesoft.com\/blog\/2020\/05\/09\/hiding-details-table-tab-on-the-fly\/\" class=\"more-link\">Continue Reading <span class=\"screen-reader-text\">&#8220;Hiding details table tab on the fly&#8221;<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16,1,8],"tags":[],"class_list":["post-2239","post","type-post","status-publish","format-standard","hentry","category-asp-net","category-php-category","category-tutorials"],"_links":{"self":[{"href":"https:\/\/xlinesoft.com\/blog\/wp-json\/wp\/v2\/posts\/2239","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xlinesoft.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xlinesoft.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xlinesoft.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xlinesoft.com\/blog\/wp-json\/wp\/v2\/comments?post=2239"}],"version-history":[{"count":7,"href":"https:\/\/xlinesoft.com\/blog\/wp-json\/wp\/v2\/posts\/2239\/revisions"}],"predecessor-version":[{"id":2247,"href":"https:\/\/xlinesoft.com\/blog\/wp-json\/wp\/v2\/posts\/2239\/revisions\/2247"}],"wp:attachment":[{"href":"https:\/\/xlinesoft.com\/blog\/wp-json\/wp\/v2\/media?parent=2239"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xlinesoft.com\/blog\/wp-json\/wp\/v2\/categories?post=2239"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xlinesoft.com\/blog\/wp-json\/wp\/v2\/tags?post=2239"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}