{"id":2844,"date":"2015-05-19T18:49:47","date_gmt":"2015-05-19T14:49:47","guid":{"rendered":"http:\/\/www.dhtmlx.com\/blog\/?p=2844"},"modified":"2023-05-05T13:41:23","modified_gmt":"2023-05-05T10:41:23","slug":"file-system-with-dhtmlxfileselector","status":"publish","type":"post","link":"https:\/\/dhtmlx.com\/blog\/file-system-with-dhtmlxfileselector\/","title":{"rendered":"Your Actual File System with dhtmlxFileSelector"},"content":{"rendered":"<p>Not so long ago we presented a <a href=\"https:\/\/dhtmlx.com\/blog\/dhtmlxdataselector-organizing-data\/\" target=\"_blank\">macro component<\/a> for convenient selection of data from database. This time we&#8217;d like to share the similar solution, but the purpose of it is quite different &#8211; it provides the ability to read your file system easily. So, meet another DHTMLX mini component &#8211; dhtmlxFileSelector.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2015\/05\/file-selector-terrace.png\" alt=\"file-select\" width=\"562\" height=\"372\" class=\"aligncenter size-full wp-image-2845\" srcset=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2015\/05\/file-selector-terrace.png 562w, https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2015\/05\/file-selector-terrace-300x198.png 300w\" sizes=\"auto, (max-width: 562px) 100vw, 562px\" \/><br \/>\n<!--more--><br \/>\n<strong>What is dhtmlxFileSelector?<\/strong><\/p>\n<p>Like Data Selector, dhtmlxFileSelector represents JavaScript component with rich select functionality. So you have the ability to open a file select dialog to find and select the needed file.<\/p>\n<p><strong>Features<\/strong><\/p>\n<p>1) Representation of your actual file system.<\/p>\n<p>2) Integration with dhtmlxForm.<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2015\/05\/file-selector-form.png\" alt=\"file selector with form\" width=\"571\" height=\"517\" class=\"aligncenter size-full wp-image-2846\" srcset=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2015\/05\/file-selector-form.png 571w, https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2015\/05\/file-selector-form-300x271.png 300w\" sizes=\"auto, (max-width: 571px) 100vw, 571px\" \/><\/p>\n<p>We could provide integration with other DHTMLX components. Leave us your comments about where you may use dhtmlxFileSelector, we&#8217;ll gladly consider to share ready solutions.<\/p>\n<p>3) Localization support<\/p>\n<p>Standard functionality also includes localization support for buttons, windows caption and grid columns.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2015\/05\/localization-fileselector-de.png\" alt=\"localization-fileselector-de\" width=\"565\" height=\"375\" class=\"aligncenter size-full wp-image-2847\" srcset=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2015\/05\/localization-fileselector-de.png 565w, https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2015\/05\/localization-fileselector-de-300x199.png 300w\" sizes=\"auto, (max-width: 565px) 100vw, 565px\" \/><\/p>\n<p><strong>Usage<\/strong><\/p>\n<p>1) Include dhtmlx.js\/css and dhtmlxfileselector.js\/css on your page.<\/p>\n<blockquote><p>Note: dhtmlx js\/css should be inserted before dhtmlxfileselector 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\/dhtmlxfileselector.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\/dhtmlxfileselector.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>2) Create an instance of FileSelector:<\/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> myFileSelector <span class=\"sy0\">=<\/span> <span class=\"kw1\">new<\/span> dhtmlXFileSelector<span class=\"br0\">&#40;<\/span><span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; url<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;reader.php&quot;<\/span><span class=\"sy0\">,<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &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; <span class=\"co1\">\/\/ path for toolbar icons<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><\/div><\/div>\n<p>3) After you inited FileSelector, you need to attach the onSelect event to handle file that is 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> myFileSelector.<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=\"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>4) Show dialog window:<\/p>\n<div class=\"codecolorer-container javascript default codecolorer-noborder\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"javascript codecolorer\">myFileSelector.<span class=\"me1\">show<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><\/div><\/div>\n<p>That\u2019s all you need to start using the component right now.<\/p>\n<blockquote><p>Note: If you&#8217;d like to use FileSelector as part of the form, you need the following init:<\/p><\/blockquote>\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; &nbsp; &nbsp;<span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; type<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;fileselector&quot;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; ...<span class=\"sy0\">,<\/span><br \/>\n&nbsp; &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; &nbsp; image_path<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;codebase\/imgs\/&quot;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; icons_path<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;codebase\/imgs\/&quot;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; full_path<span class=\"sy0\">:<\/span> <span class=\"kw2\">true<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp;<span class=\"br0\">&#125;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &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>Package includes examples that demonstrate how to read your file system, generate xml  response and how to customize grid columns.<\/p>\n<p><strong>Download links<\/strong><\/p>\n<p>If you&#8217;re already using dhtmlxSuite, you may download the separate package of dhtmlxFileSelector. <a href=\"https:\/\/dhtmlx.com\/x\/download\/regular\/betas\/dhtmlxFileSelector_v10_std.zip\" target=\"_blank\">Download dhtmlxFileSelector.<\/a><\/p>\n<p>If you aren&#8217;t using dhtmlxSuite, please download full package that contains the library with a new mini-component. <a href=\"https:\/\/dhtmlx.com\/x\/download\/regular\/betas\/dhtmlxFileSelector_v10_std_dhtmlxSuite_v421_std.zip\" target=\"_blank\">Download dhtmlxSuite together with FileSelector component.<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Not so long ago we presented a macro component for convenient selection of data from database. This time we&#8217;d like to share the similar solution, but the purpose of &#8230;<\/p>\n","protected":false},"author":2,"featured_media":3413,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17,72,1,38],"tags":[33,18],"class_list":["post-2844","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-posts-for-codeproject-com","category-general","category-uncategorized","category-visible","tag-all-posts","tag-labs"],"_links":{"self":[{"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/posts\/2844","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=2844"}],"version-history":[{"count":1,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/posts\/2844\/revisions"}],"predecessor-version":[{"id":11399,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/posts\/2844\/revisions\/11399"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/media\/3413"}],"wp:attachment":[{"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/media?parent=2844"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/categories?post=2844"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/tags?post=2844"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}