Pivot Column Data Issue

Am doing trail for Webix Pivot and finding one issue during processing of data.Below mentioned is the requirement:

Having one column as Rank which has Numeric data example as 1, 2 and so on. However while displaying this column data in pivot i don’t want to display it as is and instead wanted to drive some logic within the same For Example:

If for any Row the rank is 2 will display it as range 1-3, and if Rank is 4 will display as 4-6 and if 11 will display as 8+ and also should be able to use functionality of Min, max and count along with this logic.

Please advise if the same can be accommodated using Webix Pivot control.

Hello,

you can use scheme $init:

http://webix.com/snippet/09068a02

i placed rank column in pivot values section but it is not working because i am try to replace number to char
kindly confirm can we replace number to char in column not in row

The same solution can be applied to columns.
sheme.$init can be used to process any property of the original dataset

http://webix.com/snippet/449d6929

I want to replace gdp value to some char is that possible?

webix.ui({
  id:"pivot",
  view:"pivot",
  height:400,
  width:1000,
  scheme:{
    $init: function(item){
        item.gdp= item.gdp.toString().replace(/^20/,"1-3");//my change 
      
    }
  },
  structure: {
    rows: ["form", "name"],
    columns: ["year"],
    values: [{ name:"gdp", operation:"sum"}, { name:"oil", operation:"sum"}]
  },
  data:pivot_dataset
});

In the above snippet, you convert a numeric value of GDP to the string and later attempts to sum GDP values, which doesn’t have a sense.

You can apply any data transformations in scheme.$init, but you can’t apply math operations for non-numerical values, from such transformations.

i dont want to do any math operation with GDP i just want to display data like if gdp value is 1 i want to show 1-3
replace is working on header level its wont work on column level

It works for values, but values are formatted as numbers at the end ( as they are expected to be numbers ) which hides the initial data transformation.

http://webix.com/snippet/e474f442

If you want to format data after grouping, you need to define a custom format handler

http://webix.com/snippet/5eb222b9

Thanks maksim but some how my code is not working.i write one alert with in onBeforeRender fuction but it is not coming during loading page but all pivot fuction working .
so my question is are you use another way to call onBeforeRender: function

		webix.ui({
  		  id:"pivot",
  		container: "gridContainer",
  		  view:"pivot",
  		  height:400,
  		  width:1000,
  		  structure: {
  		    rows: pivotRows,
  		    columns: pivotColoumns,
  		    values: pivotValues
  		  },
  		on:{
  		    onBeforeRender: function(config){  
  		    	alert("in123");
  		      var columns = config.header;
  		    	alert(columns[i].id);
  		      for(var i=0; i< columns.length;i++){                     
  		        if (columns[i].id.match(/_Rank/i)){
  		        	columns[i].format = function(value) {            
  		            if (value=="6") return "1-3";
  		              return value;
  		          }
  		       	}
  		      }
  		    }
  		  },
  		  data:pivot_dataset
  		});

and currently i am using webix version 3.1.1 and you are using version 4.1.0
so is this reason at my end onBeforeRender function not working
kindly provide solution

Sorry, but why not update to the latest version? The API of pivot is backward compatible. So there will no or minimal changes.

http://docs.webix.com/migration.html#webix4041

Thanks for above feedback.

Need another help on the same. We need to clear / show blank values of all parent items after grouping. So how can we identify the parent items after pivoting data.

Please check http://webix.com/snippet/e473bb6d

Similar to formatting, you can redefine a cell’s template, here you have access to full row object and can provide different rendering logic for parent rows.

Hi, Thanks for your response and to confirm its working fine.

However further have additional issues processing one scenario:

Whenever some field selected in Rows / Values we don’t want application to display pivot data for specific combination.

For instance: If i select Country & Continent as Rows, to see associated Values for gdp & oil. My scenario, if whenever user select Continent i don’t want to see gdp Value for entire report.

In either case (Rows/ Values) if “Continent” Field is selected Value should not be shown.

Hi, Thanks for your response and to confirm its working fine.

However further have additional issues processing one scenario:

Whenever some field selected in Rows / Values we don’t want application to display pivot data for specific combination.

For instance: If i select Country & Continent as Rows, to see associated Values for gdp & oil. My scenario, if whenever user select Continent i don’t want to see gdp Value for entire report.

In either case (Rows/ Values) if “Continent” Field is selected Value should not be shown.
check in below link
http://webix.com/snippet/e473bb6d

Hi,

I see your case. It has sense, but such scenarios are too specialized and I don’t see how common solution can be created.

On other hand, the pivot popup is a normal Webix UI, so you can access any list in the popup and add your own rules ( if item A is added to the “rows”, remove item B from “fields”, etc. )

Check samples/05_customization/04_fields_tree.html ( sample show a different use-case but uses the similar approach to modify behavior of configuration popup )