{"id":2813,"date":"2015-05-08T15:50:01","date_gmt":"2015-05-08T11:50:01","guid":{"rendered":"http:\/\/www.dhtmlx.com\/blog\/?p=2813"},"modified":"2023-05-30T16:49:26","modified_gmt":"2023-05-30T13:49:26","slug":"dhtmlxdataselector-organizing-data","status":"publish","type":"post","link":"https:\/\/dhtmlx.com\/blog\/dhtmlxdataselector-organizing-data\/","title":{"rendered":"dhtmlxDataSelector: Macro-Component for Organizing Your Data"},"content":{"rendered":"<p>Our team has developed several macro-components that won&#8217;t be officially included in the dhtmlxSuite package, but they represent some interesting and useful solutions that you can use in your apps. And today we are glad to introduce the first macro-component &#8211; dhtmlxDataSelector.<\/p>\n<p><strong>What is dhtmlxDataSelector?<\/strong><\/p>\n<p>dhtmlxDataSelector is a JavaScript component that will help you to overcome the limits of information that can be placed in the combobox. It represents rich select functionality with ability to get large sets of data out of the database, group and structure these data. <\/p>\n<p><strong>Features<\/strong><\/p>\n<p>1) Advanced searching for flexible work with the data. <\/p>\n<p>This feature is really convenient if you have the database with a huge number of employees, their addresses and some other details. Based on your needs you can group the data and set any nesting level.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2015\/05\/data-selector.png\" alt=\"rich select javascript\" width=\"561\" height=\"376\" class=\"aligncenter size-full wp-image-2816\" srcset=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2015\/05\/data-selector.png 561w, https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2015\/05\/data-selector-300x201.png 300w\" sizes=\"auto, (max-width: 561px) 100vw, 561px\" \/><br \/>\n<!--more--><br \/>\n2) Easy integration with <a href=\"https:\/\/dhtmlx.com\/docs\/products\/dhtmlxForm\/\" target=\"_blank\">dhtmlxForm<\/a>. <\/p>\n<p>This ability increases the number of possible usage options of this component. You can easily integrate it in your app and start using it right now.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2015\/05\/attach-to-form.png\" alt=\"Rich select in form\" width=\"568\" height=\"507\" class=\"aligncenter size-full wp-image-2817\" srcset=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2015\/05\/attach-to-form.png 568w, https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2015\/05\/attach-to-form-300x267.png 300w\" sizes=\"auto, (max-width: 568px) 100vw, 568px\" \/><\/p>\n<p>3) Localization support.<\/p>\n<p>This feature provides the ability to translate buttons and set caption to the window.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2015\/05\/localization-fr.png\" alt=\"localization data selector\" width=\"554\" height=\"394\" class=\"aligncenter size-full wp-image-2818\" srcset=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2015\/05\/localization-fr.png 554w, https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2015\/05\/localization-fr-300x213.png 300w\" sizes=\"auto, (max-width: 554px) 100vw, 554px\" \/><\/p>\n<p>Apart from the described features, lost of others can be implemented in dhtmlxDataSelector. We are open to your suggestions.<\/p>\n<p><strong>Usage<\/strong><\/p>\n<p>Use the following instructions to start working with the component. <\/p>\n<p>First you need to include dhtmlx.js\/css and dhtmlxdataselector.js\/css on your page. <\/p>\n<blockquote><p>Note: dhtmlx js\/css should be inserted before dhtmlxdataselector js\/css.<\/p><\/blockquote>\n<div class=\"codecolorer-container javascript default codecolorer-noborder\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"javascript codecolorer\"><span class=\"sy0\">&lt;<\/span>head<span class=\"sy0\">&gt;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"sy0\">&lt;<\/span>link rel<span class=\"sy0\">=<\/span><span class=\"st0\">&quot;stylesheet&quot;<\/span> type<span class=\"sy0\">=<\/span><span class=\"st0\">&quot;text\/css&quot;<\/span> href<span class=\"sy0\">=<\/span><span class=\"st0\">&quot;codebase\/dhtmlx.css&quot;<\/span><span class=\"sy0\">\/&gt;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"sy0\">&lt;<\/span>link rel<span class=\"sy0\">=<\/span><span class=\"st0\">&quot;stylesheet&quot;<\/span> type<span class=\"sy0\">=<\/span><span class=\"st0\">&quot;text\/css&quot;<\/span> href<span class=\"sy0\">=<\/span><span class=\"st0\">&quot;codebase\/dhtmlxdataselector.css&quot;<\/span><span class=\"sy0\">\/&gt;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"sy0\">&lt;<\/span>script src<span class=\"sy0\">=<\/span><span class=\"st0\">&quot;codebase\/dhtmlx.js&quot;<\/span><span class=\"sy0\">&gt;&lt;\/<\/span>script<span class=\"sy0\">&gt;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"sy0\">&lt;<\/span>script src<span class=\"sy0\">=<\/span><span class=\"st0\">&quot;codebase\/dhtmlxdataselector.js&quot;<\/span><span class=\"sy0\">&gt;&lt;\/<\/span>script<span class=\"sy0\">&gt;<\/span><br \/>\n<span class=\"sy0\">&lt;\/<\/span>head<span class=\"sy0\">&gt;<\/span><\/div><\/div>\n<p>Then you need to create an instance of DataSelector:<\/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> myDataSelector <span class=\"sy0\">=<\/span> <span class=\"kw1\">new<\/span> dhtmlXDataSelector<span class=\"br0\">&#40;<\/span><span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; url<span class=\"sy0\">:<\/span> &nbsp; &nbsp; &nbsp; &nbsp;<span class=\"st0\">&quot;data_static.php&quot;<\/span><span class=\"sy0\">,<\/span> &nbsp;<span class=\"co1\">\/\/ url to get data<\/span><br \/>\n&nbsp; &nbsp; image_path<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;codebase\/imgs\/&quot;<\/span><span class=\"sy0\">,<\/span> &nbsp; <span class=\"co1\">\/\/ path for grid images<\/span><br \/>\n&nbsp; &nbsp; icons_path<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;codebase\/imgs\/&quot;<\/span> &nbsp; &nbsp;<span class=\"co1\">\/\/ path to toolbar icons<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><\/div><\/div>\n<p>After you inited DataSelector, you need to attach the onSelect event to handle value selected by the user:<\/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> myDataSelector.<span class=\"me1\">attachEvent<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">&quot;onSelect&quot;<\/span><span class=\"sy0\">,<\/span> <span class=\"kw1\">function<\/span><span class=\"br0\">&#40;<\/span>id<span class=\"sy0\">,<\/span> value<span class=\"br0\">&#41;<\/span><span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"co1\">\/\/ your code here<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><\/div><\/div>\n<p>And finally &#8211; show dialog window:<\/p>\n<div class=\"codecolorer-container javascript default codecolorer-noborder\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"javascript codecolorer\">myDataSelector.<span class=\"me1\">show<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><\/div><\/div>\n<p>And that&#8217;s all. Quite easy, isn&#8217;t it?<\/p>\n<p>If you&#8217;d like to use DataSelector as part of the form, you need the following init:<\/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> formData <span class=\"sy0\">=<\/span> <span class=\"br0\">&#91;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp;type<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;dataselector&quot;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp;...<span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp;url<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;data_static.php&quot;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp;image_path<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;codebase\/imgs\/&quot;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp;icons_path<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;codebase\/imgs\/&quot;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; ... <span class=\"me1\">other<\/span> form items<br \/>\n<span class=\"br0\">&#93;<\/span><span class=\"sy0\">;<\/span><br \/>\n<span class=\"kw1\">var<\/span> myForm <span class=\"sy0\">=<\/span> <span class=\"kw1\">new<\/span> dhtmlXForm<span class=\"br0\">&#40;<\/span><span class=\"st0\">&quot;parentId&quot;<\/span><span class=\"sy0\">,<\/span> formData<span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><\/div><\/div>\n<p>The package includes example that demonstrates how to get data from database and xml structure.<\/p>\n<p><strong>Download links<\/strong><\/p>\n<p>You may download <a href=\"https:\/\/dhtmlx.com\/x\/download\/regular\/betas\/dhtmlxDataSelector_v10_std.zip\" target=\"_blank\">dhtmlxDataSelector as a separate package<\/a> if you are already using dhtmlxSuite. Follow the instructions given above to include the component.<\/p>\n<p>Note: to make dhtmlxDataSelector work, you need dhtmlxSuite anyway. So, if you&#8217;d like to try a new component, you can download the package that contains <a href=\"https:\/\/dhtmlx.com\/x\/download\/regular\/betas\/dhtmlxDataSelector_v10_std_dhtmlxSuite_v42_std.zip\" target=\"_blank\">dhtmlxSuite library together with dhtmlxDataSelector<\/a>. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Our team has developed several macro-components that won&#8217;t be officially included in the dhtmlxSuite package, but they represent some interesting and useful solutions that you can use in your &#8230;<\/p>\n","protected":false},"author":2,"featured_media":3300,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17,70,1,38],"tags":[33,18,31,10],"class_list":["post-2813","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-posts-for-codeproject-com","category-releases","category-uncategorized","category-visible","tag-all-posts","tag-labs","tag-form","tag-dhtmlxsuite"],"_links":{"self":[{"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/posts\/2813","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=2813"}],"version-history":[{"count":1,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/posts\/2813\/revisions"}],"predecessor-version":[{"id":11402,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/posts\/2813\/revisions\/11402"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/media\/3300"}],"wp:attachment":[{"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/media?parent=2813"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/categories?post=2813"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/tags?post=2813"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}