{"id":5380,"date":"2018-08-24T15:34:04","date_gmt":"2018-08-24T12:34:04","guid":{"rendered":"https:\/\/dhtmlx.com\/blog\/?p=5380"},"modified":"2025-03-10T17:46:00","modified_gmt":"2025-03-10T14:46:00","slug":"frequent-questions-developers-ask-javascript-pivot-table","status":"publish","type":"post","link":"https:\/\/dhtmlx.com\/blog\/frequent-questions-developers-ask-javascript-pivot-table\/","title":{"rendered":"Most Frequent Questions from Developers about Our JavaScript Pivot Table"},"content":{"rendered":"<p>dhtmlxPivot was introduced in August 2017. Over the last year our technical support team has faced various questions from the users of our <a href=\"https:\/\/dhtmlx.com\/docs\/products\/dhtmlxPivot\/\" target=\"_blank\" rel=\"noopener\">JavaScript pivot table<\/a> about its configuration and customization options.<\/p>\n<p>As JavaScript pivot tables are widely applied in BI apps used by companies of any size, they need to be fine-tuned to meet the requirements of a particular business or country. Pivot tables help end users to analyze different types of data such as financial data, flows of capital, products, human resources, and what not. Pivot tables are supposed to process values in different formats what raises technical questions on behalf of developers, as they need to manipulate content in pivot grid cells and adjust it to the needs of the project they work on.<\/p>\n<p>We&#8217;ve gathered together some of the most common issues developers deal with customizing JavaScript pivot tables. So here&#8217;s a wrap-up of frequent questions and our answers.<\/p>\n<h6>Is it possible to add currency symbols to the values of cells?<\/h6>\n<p>Yes, just like any other symbols currency symbols can be added to cell values with the help of the <a href=\"https:\/\/docs.dhtmlx.com\/pivot\/1-5\/api__pivot_customformat_config.html\" target=\"_blank\" rel=\"noopener\">customFormat<\/a> configuration property. You can define which values require custom symbols depending on the operation applied to data in a column as shown in the example below:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5395\" src=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2018\/08\/currency_symols900.png\" alt=\"Currency symbols for pivot\" width=\"900\" height=\"149\" srcset=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2018\/08\/currency_symols900.png 900w, https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2018\/08\/currency_symols900-300x50.png 300w, https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2018\/08\/currency_symols900-768x127.png 768w\" sizes=\"auto, (max-width: 900px) 100vw, 900px\" \/><\/p>\n<div class=\"codecolorer-container javascript default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"javascript codecolorer\">customFormat<span class=\"sy0\">:<\/span> <span class=\"kw1\">function<\/span> <span class=\"br0\">&#40;<\/span>cellValue<span class=\"sy0\">,<\/span> method<span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n<span class=\"kw1\">if<\/span> <span class=\"br0\">&#40;<\/span>method <span class=\"sy0\">===<\/span> <span class=\"st0\">&quot;count&quot;<\/span><span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n<span class=\"kw1\">return<\/span> cellValue.<span class=\"me1\">toLocaleString<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">&quot;de&quot;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><br \/>\n<span class=\"kw1\">return<\/span> <span class=\"st0\">&quot;\u20ac &quot;<\/span> <span class=\"sy0\">+<\/span> cellValue.<span class=\"me1\">toLocaleString<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">&quot;de&quot;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><\/div><\/div>\n<p>Besides, as you see from the example, you can also apply specific localization rules that dictate how to round numbers in cells according to the locale you need (German locale in our case).<\/p>\n<p><a href=\"https:\/\/docs.dhtmlx.com\/pivot\/samples\/03_customization\/05_custom_formatting.html\" target=\"_blank\" rel=\"noopener\">Check custom formats sample &gt;<\/a><\/p>\n<h6>Can we change values of cells for other custom elements?<\/h6>\n<p>Yes, you can change values of cells for any custom content you need to be shown in your JavaScript pivot table. For this purpose you can add a custom element to the cell like an icon, link, checkbox, button etc, and even create an event handler for it, for example, to show a popup after a click on the cell content.<\/p>\n<p>In our case we added checkboxes to the cells in columns with the Count operation when the cell value is greater than 3.<br \/>\n<a href=\"https:\/\/docs.dhtmlx.com\/pivot\/1-5\/guides__customization.html\" target=\"_blank\" rel=\"noopener\">Read more in docs &gt;<\/a><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5398\" src=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2018\/08\/custom_templates900.png\" alt=\"custom templates for pivot\" width=\"900\" height=\"222\" srcset=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2018\/08\/custom_templates900.png 900w, https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2018\/08\/custom_templates900-300x74.png 300w, https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2018\/08\/custom_templates900-768x189.png 768w\" sizes=\"auto, (max-width: 900px) 100vw, 900px\" \/><\/p>\n<div class=\"codecolorer-container javascript default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"javascript codecolorer\">cellTemplate<span class=\"sy0\">:<\/span> <span class=\"kw1\">function<\/span> <span class=\"br0\">&#40;<\/span>text<span class=\"sy0\">,<\/span> row<span class=\"sy0\">,<\/span> col<span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n<span class=\"kw1\">if<\/span> <span class=\"br0\">&#40;<\/span>col.<span class=\"me1\">method<\/span> <span class=\"sy0\">===<\/span> <span class=\"st0\">&quot;sum&quot;<\/span><span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n<span class=\"kw1\">return<\/span> <span class=\"st0\">'<\/span><\/div><\/div>\n<div class=\"customCell\">&#8216; + (text||&#8221;&#8221;) + &#8216;<\/div>\n<p>&#8216;<br \/>\n} else {<br \/>\nreturn &#8216;<input class=\"custom_div\" disabled=\"disabled\" type=\"checkbox\" \/> 3 ? &#8220;checked&#8221; : &#8220;&#8221;) + &#8216; &gt;<\/p>\n<p>&#8216;<br \/>\n}<br \/>\n}<\/p>\n<p><a href=\"https:\/\/docs.dhtmlx.com\/pivot\/samples\/02_styling\/04_cell_templates.html\" target=\"_blank\" rel=\"noopener\">Check cell templates sample &gt;<\/a><\/p>\n<h6>Does JavaScript pivot table allow adding custom operations for values?<\/h6>\n<p>You can add any mathematical operations you need by means of the <a href=\"https:\/\/docs.dhtmlx.com\/pivot\/1-5\/api__pivot_addmathmethod.html\" target=\"_blank\" rel=\"noopener\">addMathMethod<\/a> method.<\/p>\n<div class=\"codecolorer-container javascript default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"javascript codecolorer\">myPivot.<span class=\"me1\">addMathMethod<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">&quot;avr&quot;<\/span><span class=\"sy0\">,<\/span> <span class=\"st0\">&quot;Avr&quot;<\/span><span class=\"sy0\">,<\/span> <span class=\"br0\">&#40;<\/span>cellData<span class=\"br0\">&#41;<\/span> <span class=\"sy0\">=&amp;<\/span>gt<span class=\"sy0\">;<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n<span class=\"kw1\">const<\/span> sum <span class=\"sy0\">=<\/span> cellData.<span class=\"me1\">reduce<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#40;<\/span>el<span class=\"sy0\">,<\/span> all<span class=\"br0\">&#41;<\/span> <span class=\"sy0\">=&amp;<\/span>gt<span class=\"sy0\">;<\/span> all <span class=\"sy0\">+=<\/span> el<span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n<span class=\"kw1\">return<\/span> <span class=\"br0\">&#40;<\/span>sum <span class=\"sy0\">\/<\/span> cellData.<span class=\"me1\">length<\/span><span class=\"br0\">&#41;<\/span>.<span class=\"me1\">toFixed<\/span><span class=\"br0\">&#40;<\/span><span class=\"nu0\">3<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><\/div><\/div>\n<p>You can redefine the existing methods and add your own custom ones, with which you can specify formats of cell values the way you need. For example, you can apply particular localization rules:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5399\" src=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2018\/08\/custom_method900.png\" alt=\"custom methods for pivot\" width=\"900\" height=\"222\" srcset=\"https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2018\/08\/custom_method900.png 900w, https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2018\/08\/custom_method900-300x74.png 300w, https:\/\/dhtmlx.com\/blog\/wp-content\/uploads\/2018\/08\/custom_method900-768x189.png 768w\" sizes=\"auto, (max-width: 900px) 100vw, 900px\" \/><\/p>\n<div class=\"codecolorer-container javascript default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"javascript codecolorer\">pivot.<span class=\"me1\">addMathMethod<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">&quot;sum&quot;<\/span><span class=\"sy0\">,<\/span> <span class=\"st0\">'SUM'<\/span><span class=\"sy0\">,<\/span> <span class=\"kw1\">function<\/span> <span class=\"br0\">&#40;<\/span>cellData<span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n<span class=\"kw1\">var<\/span> sum <span class=\"sy0\">=<\/span> cellData.<span class=\"me1\">reduce<\/span><span class=\"br0\">&#40;<\/span><span class=\"kw1\">function<\/span> <span class=\"br0\">&#40;<\/span>el<span class=\"sy0\">,<\/span> all<span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#123;<\/span> <span class=\"kw1\">return<\/span> all <span class=\"sy0\">+=<\/span> el <span class=\"br0\">&#125;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\n<span class=\"kw1\">return<\/span> sum.<span class=\"me1\">toLocaleString<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">&quot;en&quot;<\/span><span class=\"br0\">&#41;<\/span><br \/>\n<span class=\"br0\">&#125;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/span><br \/>\npivot.<span class=\"me1\">addMathMethod<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">&quot;min&quot;<\/span><span class=\"sy0\">,<\/span> <span class=\"st0\">'MIN'<\/span><span class=\"sy0\">,<\/span> <span class=\"kw1\">function<\/span> <span class=\"br0\">&#40;<\/span>cellData<span class=\"br0\">&#41;<\/span> <span class=\"br0\">&#123;<\/span><br \/>\n<span class=\"kw1\">return<\/span> <span class=\"br0\">&#40;<\/span><span class=\"kw4\">Math<\/span>.<span class=\"me1\">min<\/span>.<span class=\"me1\">apply<\/span><span class=\"br0\">&#40;<\/span><span class=\"kw2\">null<\/span><span class=\"sy0\">,<\/span>cellData<span class=\"br0\">&#41;<\/span><span class=\"br0\">&#41;<\/span>.<span class=\"me1\">toLocaleString<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">&quot;en&quot;<\/span><span class=\"br0\">&#41;<\/span><span class=\"sy0\">;<\/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_customization\/04_custom_methods.html\" target=\"_blank\" rel=\"noopener\">Check custom methods sample &gt;<\/a><\/p>\n<p>These were some of the most frequent questions from developers about our JavaScript pivot table component that our technical support team has encountered so far. Hope our answers turned out to be useful for you too!<\/p>\n<p>Currently we\u2019re working on the new functionality for dhtmlxPivot for the next updates. Vote for the features you require and check our roadmap <a href=\"https:\/\/trello.com\/b\/TmXJeawV\/pivot-roadmap\" target=\"_blank\" rel=\"noopener\">here<\/a>.<\/p>\n<p><strong><a href=\"https:\/\/dhtmlx.com\/docs\/products\/dhtmlxPivot\/download.shtml\" target=\"_blank\" rel=\"noopener\">Download dhtmlxPivot 1.3 trial version<\/a><br \/>\n<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>dhtmlxPivot was introduced in August 2017. Over the last year our technical support team has faced various questions from the users of our JavaScript pivot table about its configuration &#8230;<\/p>\n","protected":false},"author":101012,"featured_media":5392,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[72,1],"tags":[33,57],"class_list":["post-5380","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-general","category-uncategorized","tag-all-posts","tag-pivot"],"_links":{"self":[{"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/posts\/5380","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=5380"}],"version-history":[{"count":4,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/posts\/5380\/revisions"}],"predecessor-version":[{"id":13475,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/posts\/5380\/revisions\/13475"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/media\/5392"}],"wp:attachment":[{"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/media?parent=5380"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/categories?post=5380"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dhtmlx.com\/blog\/wp-json\/wp\/v2\/tags?post=5380"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}