EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: Opan Mustopah on May 10, 2015, 07:37:57 PM



Title: pivot grid extension
Post by: Opan Mustopah on May 10, 2015, 07:37:57 PM
hello again,

want to ask about pivot gird extension, btw its great plugin.

after seeing and try pivot grid demo, i see, value on pivot grid is only support for number value, but not string value,

is it possible to use string as value on pivot grid? because when i try to mov field that contain string value to 'value' panel, all value become 0 (zero)

thanks in adnvance


Title: Re: pivot grid extension
Post by: stworthy on May 11, 2015, 08:13:43 AM
You have to use numeric for value fields because they will be calculated.


Title: Re: pivot grid extension
Post by: Opan Mustopah on May 11, 2015, 08:01:15 PM
thanks stworthy for your answer.
but,

is there a way to using like formatter properties on datagrid, so i can do something like bind the value with another value contains string?
because i really need this plugin to support that feature.

thanks in advance


Title: Re: pivot grid extension
Post by: stworthy on May 11, 2015, 08:13:45 PM
The default operator on the value fields is 'sum'. You can try to extend other operators to fit your requirement. For more information please refer to http://www.jeasyui.com/extension/pivotgrid.php.
Code:
//implement the 'sum' operator
$.extend($.fn.pivotgrid.defaults.operators, {
sum: function(rows, field){
var opts = $(this).pivotgrid('options');
var v = 0;
$.map(rows,function(row){
v += parseFloat(row[field])||0;
});
return v.toFixed(opts.valuePrecision);
}
});


Title: Re: pivot grid extension
Post by: Opan Mustopah on May 11, 2015, 08:51:48 PM
thanks stworthy for your fast response,
i'll try it and i'll report it to you if its works or not.