{"id":2460,"date":"2014-09-23T18:56:01","date_gmt":"2014-09-23T14:56:01","guid":{"rendered":"http:\/\/www.dhtmlx.com\/blog\/?p=2460"},"modified":"2023-05-05T13:58:35","modified_gmt":"2023-05-05T10:58:35","slug":"different-content-in-the-same-cell","status":"publish","type":"post","link":"https:\/\/dhtmlx.com\/blog\/different-content-in-the-same-cell\/","title":{"rendered":"DHTMLX Little-Known Features: Different Content in the Same Cell"},"content":{"rendered":"<p>DHTMLX library has lots of features and provides numerous abilities, but not all of them are discovered at first glance. We want to share some tips that you might have missed but they may appear quite useful.<\/p>\n<p>We\u2019ll start with such called <strong>\u201cviews\u201d<\/strong>, the feature of a cell. <\/p>\n<p>In the components that have cells (i.e. accordion, layout, tabbar and windows), there is a possibility to <a href=\"https:\/\/docs.dhtmlx.com\/accordion__views.html\" target=\"_blank\">show different content in the same cell<\/a>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2014\/09\/tree-def-grid-2.png\" alt=\"content-in-one-cell\" width=\"600\" height=\"503\" class=\"aligncenter size-full wp-image-2461\" srcset=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2014\/09\/tree-def-grid-2.png 600w, https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2014\/09\/tree-def-grid-2-300x251.png 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p><strong>How it works?<\/strong><\/p>\n<p>As an example, let&#8217;s take a layout and attach some components to the cell \u201cb\u201d.<\/p>\n<p>\nEach cell shows the view &#8220;def&#8221; by default (empty without any content). Then just attach the content you need:\n<\/p>\n<div class=\"codecolorer-container javascript default codecolorer-noborder\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"javascript codecolorer\"><span class=\"kw1\">var<\/span> myMenu <span class=\"sy0\">=<\/span> myLayout.<span class=\"me1\">cells<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">&quot;b&quot;<\/span><span class=\"br0\">&#41;<\/span>.<span class=\"me1\">attachMenu<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n<span class=\"kw1\">var<\/span> myGrid <span class=\"sy0\">=<\/span> myLayout.<span class=\"me1\">cells<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">&quot;b&quot;<\/span><span class=\"br0\">&#41;<\/span>.<span class=\"me1\">attachGrid<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2014\/09\/def-view.png\" alt=\"def-view\" width=\"334\" height=\"268\" class=\"aligncenter size-full wp-image-2462\" srcset=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2014\/09\/def-view.png 334w, https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2014\/09\/def-view-300x240.png 300w\" sizes=\"auto, (max-width: 334px) 100vw, 334px\" \/><\/p>\n<p>\nThen you can just switch to another view and attach another content. Name these views as you like and determine which view should be shown. If the view \u201ctree\u201d doesn\u2019t exist, the command showView(&#8220;tree&#8221;) creates it. <\/p>\n<div class=\"codecolorer-container javascript default codecolorer-noborder\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"javascript codecolorer\">myLayout.<span class=\"me1\">cells<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">&quot;b&quot;<\/span><span class=\"br0\">&#41;<\/span>.<span class=\"me1\">showView<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">&quot;tree&quot;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\nmyToolbar <span class=\"sy0\">=<\/span> myLayout.<span class=\"me1\">cells<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">&quot;b&quot;<\/span><span class=\"br0\">&#41;<\/span>.<span class=\"me1\">attachToolbar<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\nmyTree <span class=\"sy0\">=<\/span> myLayout.<span class=\"me1\">cells<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">&quot;b&quot;<\/span><span class=\"br0\">&#41;<\/span>.<span class=\"me1\">attachTree<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><\/div><\/div>\n<p>The view \u201cdef\u201d becomes hidden and the view \u201ctree\u201d is active now:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dhtmlx.com\/blog\/wp-content\/uploads\/2014\/09\/views_04.png\" alt=\"views\" width=\"600\" height=\"227\" class=\"aligncenter size-full wp-image-2463\" srcset=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2014\/09\/views_04.png 600w, https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2014\/09\/views_04-300x113.png 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p>If we request to show the view &#8220;def&#8221;, then it\u2019ll be restored and active again, and the view \u201ctree\u201d will become hidden. There is no limit in number of views in a cell.<\/p>\n<p>Get more details in <a href=\"https:\/\/docs.dhtmlx.com\/accordion__views.html\" target=\"_blank\">documentation<\/a> and check the <a href=\"https:\/\/dhtmlx.com\/docs\/products\/dhtmlxLayout\/samples\/01_init\/09_views.html\" target=\"_blank\">related demo<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>DHTMLX library has lots of features and provides numerous abilities, but not all of them are discovered at first glance. We want to share some tips that you might &#8230;<\/p>\n","protected":false},"author":2,"featured_media":3325,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17,71,1],"tags":[33,43,14],"class_list":["post-2460","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-posts-for-codeproject-com","category-tutorials","category-uncategorized","tag-all-posts","tag-dhtmlx-tips","tag-tips"],"_links":{"self":[{"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/posts\/2460","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/comments?post=2460"}],"version-history":[{"count":1,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/posts\/2460\/revisions"}],"predecessor-version":[{"id":11415,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/posts\/2460\/revisions\/11415"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/media\/3325"}],"wp:attachment":[{"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/media?parent=2460"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/categories?post=2460"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/tags?post=2460"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}