{"id":6579,"date":"2019-09-12T12:17:44","date_gmt":"2019-09-12T09:17:44","guid":{"rendered":"https:\/\/dhtmlx.com\/blog\/?p=6579"},"modified":"2025-09-01T11:42:12","modified_gmt":"2025-09-01T08:42:12","slug":"dhtmlxpivot-1-4-minor-update-flat-mode-export-csv-dropdown-field-selectors","status":"publish","type":"post","link":"https:\/\/dhtmlx.com\/blog\/dhtmlxpivot-1-4-minor-update-flat-mode-export-csv-dropdown-field-selectors\/","title":{"rendered":"dhtmlxPivot 1.4 Minor Update: Flat Mode, Export to CSV, and Dropdown Field Selectors"},"content":{"rendered":"<p>A long-awaited v1.4 of our <a href=\"https:\/\/dhtmlx.com\/docs\/products\/dhtmlxPivot\/\" target=\"_blank\" rel=\"noopener\">JavaScript pivot table<\/a>, a smart component for data analysis, is finally out!<\/p>\n<p>The highlight of the release is the ability to display data in a flattened pivot table with repeated row labels. Besides, now dhtmlxPivot is able to export data not only to Excel but also to the CSV format, which is lightweight and simple to use with any programming language. We also supplied the component with a wide range of events firing on various user actions in the grid and updated the UX of field selectors.<\/p>\n<p>So, let&#8217;s make a long story short&#8230;and invite you to download the latest v1.4 for <a href=\"https:\/\/dhtmlx.com\/docs\/products\/dhtmlxPivot\/download.shtml\" target=\"_blank\" rel=\"noopener\">30-day evaluation<\/a>!<\/p>\n<h5>Tree vs Flat Mode of the Grid<\/h5>\n<p>The update introduces different modes for visualizing pivot data. You can set up the desired mode according to the preferences of your end users. The tree-like structure of the grid has been used in dhtmlxPivot by default so far. V1.4 brings out the <a href=\"https:\/\/docs.dhtmlx.com\/pivot\/1-5\/guides__configuration.html\" target=\"_blank\" rel=\"noopener\"><strong>gridMode<\/strong> attribute<\/a> of the layout object, which helps to redefine the mode of displaying data and present it as a flattened table as shown in the picture below:<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6613\" src=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2019\/09\/bandicam-2019-09-12-15-34-27-379.jpg\" alt=\"Flat mode of the pivot grid\" width=\"745\" height=\"484\" srcset=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2019\/09\/bandicam-2019-09-12-15-34-27-379.jpg 745w, https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2019\/09\/bandicam-2019-09-12-15-34-27-379-300x195.jpg 300w\" sizes=\"auto, (max-width: 745px) 100vw, 745px\" \/><a href=\"https:\/\/docs.dhtmlx.com\/pivot\/samples\/01_init\/07_grid_flat_mode.html\" target=\"_blank\" rel=\"noopener\">Check the sample &gt;<\/a><\/p>\n<p>Apart from that, it&#8217;s possible to avoid duplicating row headers in the cells of the first column by specifying the <strong>repeatRowsHeaders:false<\/strong> property in the layout configuration:<\/p>\n<div class=\"codecolorer-container javascript default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"javascript codecolorer\"><span class=\"kw1\">var<\/span> pivot <span class=\"sy0\">=<\/span> <span class=\"kw1\">new<\/span> dhx.<span class=\"me1\">Pivot<\/span><span class=\"br0\">&#40;<\/span>document.<span class=\"me1\">body<\/span><span class=\"sy0\">,<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; data<span class=\"sy0\">:<\/span> dataset<span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; fields<span class=\"sy0\">:<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; rows<span class=\"sy0\">:<\/span> <span class=\"br0\">&#91;<\/span><span class=\"st0\">&quot;form&quot;<\/span><span class=\"sy0\">,<\/span> <span class=\"st0\">&quot;name&quot;<\/span><span class=\"br0\">&#93;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; columns<span class=\"sy0\">:<\/span> <span class=\"br0\">&#91;<\/span><span class=\"st0\">&quot;year&quot;<\/span><span class=\"br0\">&#93;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; values<span class=\"sy0\">:<\/span> <span class=\"br0\">&#91;<\/span><span class=\"br0\">&#123;<\/span> id<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;oil&quot;<\/span><span class=\"sy0\">,<\/span> method<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;max&quot;<\/span> <span class=\"br0\">&#125;<\/span><span class=\"sy0\">,<\/span> <span class=\"br0\">&#123;<\/span> id<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;oil&quot;<\/span><span class=\"sy0\">,<\/span> method<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;sum&quot;<\/span> <span class=\"br0\">&#125;<\/span><span class=\"br0\">&#93;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; fieldList<span class=\"sy0\">:<\/span> <span class=\"br0\">&#91;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"br0\">&#123;<\/span> id<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;name&quot;<\/span><span class=\"sy0\">,<\/span> label<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;name&quot;<\/span> <span class=\"br0\">&#125;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"co1\">\/\/ the full list of fields<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#93;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; layout<span class=\"sy0\">:<\/span> <span class=\"br0\">&#123;<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; gridMode<span class=\"sy0\">:<\/span><span class=\"st0\">&quot;flat&quot;<\/span><span class=\"sy0\">,<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; repeatRowsHeaders<span class=\"sy0\">:<\/span><span class=\"kw2\">false<\/span> &nbsp;<br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br \/>\n&nbsp; <span class=\"br0\">&#125;<\/span><br \/>\n<span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6615\" src=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2019\/09\/bandicam-2019-09-12-15-36-17-135.jpg\" alt=\"Flat mode with repeated labels\" width=\"745\" height=\"484\" srcset=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2019\/09\/bandicam-2019-09-12-15-36-17-135.jpg 745w, https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2019\/09\/bandicam-2019-09-12-15-36-17-135-300x195.jpg 300w\" sizes=\"auto, (max-width: 745px) 100vw, 745px\" \/><a href=\"https:\/\/docs.dhtmlx.com\/pivot\/samples\/01_init\/07_grid_flat_mode.html\" target=\"_blank\" rel=\"noopener\">Check the sample &gt;<\/a><br \/>\nThe new flat mode is a convenient and easy-to-read way of visualizing pivot data. It may be familiar to end users due to a similar tabular form with repeated item labels of the Excel layout.<\/p>\n<h5>Export to CSV<\/h5>\n<p>The newly introduced <strong>pivot.export.csv()<\/strong> method of the Export module enables you to export pivot data <a href=\"https:\/\/docs.dhtmlx.com\/pivot\/1-5\/guides__export.html\" target=\"_blank\" rel=\"noopener\">to the CSV format<\/a>. The export settings are quite flexible and allow for the necessary adjustments. By default, you&#8217;ll get a CSV file as a result of export. However, you can choose to export data only as a CSV string by specifying the <strong>asFile:false<\/strong> configuration property. Other settings permit converting pivot into a flat table and defining custom separators between rows and columns.<\/p>\n<p>In the example below we&#8217;ll get a CSV file named &#8220;pivot_data&#8221; with a flat structure, tabs as row separators and semicolons as column separators:<\/p>\n<div class=\"codecolorer-container javascript default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"javascript codecolorer\">pivot.<span class=\"kw5\">export<\/span>.<span class=\"me1\">csv<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#123;<\/span><br \/>\nname<span class=\"sy0\">:<\/span><span class=\"st0\">&quot;pivot_data&quot;<\/span><span class=\"sy0\">,<\/span><br \/>\nasFile<span class=\"sy0\">:<\/span><span class=\"kw2\">true<\/span><span class=\"sy0\">,<\/span><br \/>\nflat<span class=\"sy0\">:<\/span><span class=\"kw2\">true<\/span><span class=\"sy0\">,<\/span><br \/>\nrowDelimiter<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;<span class=\"es0\">\\t<\/span>&quot;<\/span><span class=\"sy0\">,<\/span><br \/>\ncolumnDelimiter<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;;&quot;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><\/div><\/div>\n<p><a href=\"https:\/\/docs.dhtmlx.com\/pivot\/samples\/03_usage\/04_export.html\" target=\"_blank\" rel=\"noopener\">Check the sample &gt;<\/a><\/p>\n<p>Please note that since v1.4 we recommend using the <strong>pivot.export.xlsx()<\/strong> method of the Export module instead of the <strong>pivot.export()<\/strong> method. Read the <a href=\"https:\/\/docs.dhtmlx.com\/pivot\/\" target=\"_blank\" rel=\"noopener\">migration article<\/a> for more details.<\/p>\n<h5>New Dropdown Field Selectors<\/h5>\n<p>In v1.4 we added a new type of field selectors. Now with the help of the <a href=\"https:\/\/docs.dhtmlx.com\/pivot\/1-5\/guides__configuration.html\" target=\"_blank\" rel=\"noopener\"><strong>fieldSelectorType<\/strong> attribute<\/a> you can define the look and feel of selectors and configure them either as loop selectors or dropdown lists:<\/p>\n<div class=\"codecolorer-container javascript default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"javascript codecolorer\"><span class=\"kw1\">var<\/span> pivot <span class=\"sy0\">=<\/span> <span class=\"kw1\">new<\/span> dhx.<span class=\"me1\">Pivot<\/span><span class=\"br0\">&#40;<\/span>document.<span class=\"me1\">body<\/span><span class=\"sy0\">,<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; data<span class=\"sy0\">:<\/span> dataset<span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; fields<span class=\"sy0\">:<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"co1\">\/\/ fields structure<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; fieldList<span class=\"sy0\">:<\/span> <span class=\"br0\">&#91;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; <span class=\"co1\">\/\/ full list of fields<\/span><br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#93;<\/span><span class=\"sy0\">,<\/span><br \/>\n&nbsp; &nbsp; layout<span class=\"sy0\">:<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n&nbsp; &nbsp; fieldSelectorType<span class=\"sy0\">:<\/span><span class=\"st0\">&quot;dropdown&quot;<\/span> &nbsp; &nbsp;<br \/>\n&nbsp; &nbsp; <span class=\"br0\">&#125;<\/span><br \/>\n&nbsp; <span class=\"br0\">&#125;<\/span><br \/>\n<span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6617\" src=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2019\/09\/bandicam-2019-09-12-15-38-21-652.jpg\" alt=\"JS Pivot dropdown selectors\" width=\"517\" height=\"152\" srcset=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2019\/09\/bandicam-2019-09-12-15-38-21-652.jpg 517w, https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2019\/09\/bandicam-2019-09-12-15-38-21-652-300x88.jpg 300w\" sizes=\"auto, (max-width: 517px) 100vw, 517px\" \/><a href=\"https:\/\/docs.dhtmlx.com\/pivot\/samples\/03_usage\/06_subfields.html\" target=\"_blank\" rel=\"noopener\">Check the sample &gt;<\/a><\/p>\n<h5>TreeGrid Events in the Pivot API<\/h5>\n<p>On top of all, starting with v1.4 dhtmlxPivot is able to listen to the grid events triggered by user actions such as clicks on cells, moving the mouse pointer, typing text in an input field, etc. The entire list of the newly added events is available <a href=\"https:\/\/docs.dhtmlx.com\/pivot\/1-5\/api__refs__grid_events.html\" target=\"_blank\" rel=\"noopener\">in the documentation<\/a>.<\/p>\n<p>We hope the update will come in useful in your projects! We&#8217;re looking forward to hearing your feedback and comments. Feel free to <a href=\"https:\/\/dhtmlx.com\/docs\/products\/dhtmlxPivot\/download.shtml\" target=\"_blank\" rel=\"noopener\">evaluate the latest version<\/a> with the help of our technical support team for free for 30 days.<\/p>\n<p>We invite our current clients to download v1.4 of dhtmlxPivot in their <a href=\"https:\/\/dhtmlx.com\/clients\/\" target=\"_blank\" rel=\"noopener\">Client&#8217;s Area<\/a>.<\/p>\n<p>Stay tuned!<\/p>\n<h5>Related Materials:<\/h5>\n<ul>\n<li><a href=\"https:\/\/docs.dhtmlx.com\/pivot\/index.html\" target=\"_blank\" rel=\"noopener\">dhtmlxPivot documentation<\/a><\/li>\n<li><a href=\"https:\/\/snippet.dhtmlx.com\/3xqkml4u?tag=pivot\" target=\"_blank\" rel=\"noopener\">Samples<\/a><\/li>\n<li>Full list <a href=\"https:\/\/docs.dhtmlx.com\/pivot\/1-5\/whatsnew.html\" target=\"_blank\" rel=\"noopener\">&#8220;What&#8217;s new in v1.4&#8221;<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>A long-awaited v1.4 of our JavaScript pivot table, a smart component for data analysis, is finally out! The highlight of the release is the ability to display data in &#8230;<\/p>\n","protected":false},"author":101012,"featured_media":6620,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[70,1,38],"tags":[33,57,4],"class_list":["post-6579","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-releases","category-uncategorized","category-visible","tag-all-posts","tag-pivot","tag-dhtmlx-updates"],"_links":{"self":[{"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/posts\/6579","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\/101012"}],"replies":[{"embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/comments?post=6579"}],"version-history":[{"count":8,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/posts\/6579\/revisions"}],"predecessor-version":[{"id":14376,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/posts\/6579\/revisions\/14376"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/media\/6620"}],"wp:attachment":[{"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/media?parent=6579"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/categories?post=6579"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/tags?post=6579"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}