Pivot table : complex data and rows templates

Hi,
We have data with complex structure :

{ id:1, task : { id:123, name: ‘Task 1’}, username: ‘bob’ }, …

I want pivot table to group rows by task, but as task is an object, all are combined into one “[object Object]” row.
I thought to find a “complex:true” that would have allowed me to user “task.id” as row but it didn’t work.
I didn’t found any way to customize pivot in order to group rows by custom function or so. Did there is a way ?

If I have to add a task_id field into my raw data, I now want to customize the rows displayed label (instead of “1” I want “Task 1” displayed) I didn’t found a row template mechanism or something like that. Did there is a way ?

Thank for your responses.

Hi,

You need to redefine column template to render object values in cells. You can change the column template within the onBeforeRender handler:

view:"pivot",
on:{
   onBeforeRender: function(config){
        var columns = config.header;
        //'i' is the index of the needed column                
        columns[i].template = function(value, item, itemId, columnId){     
              return item.id + " " + item.name; 
         }  
    }           
}

And you get the string like “123 Task 1” in the columns cells.

Here’s the sample of a similar event handler.