2

Handsontable really fits my needs when it comes to UI interaction. But was wondering if it can also pivot data.

I have Json data that looks like this:

var objectData = [
  {id: 1, name: "Ted Right", gender: "male"},
  {id: 2, name: "Bill Allan", gender: "male"},
  {id: 1, name: "Joan Well", gender: "female"},  
  {id: 2, name: "Jane Doe", gender: "female"}
];

where id value should be the row name and the gender value should be the column header and the name is the value in the table.

theHaggis
  • 615
  • 7
  • 18
  • It doesnt' make sense to set column header to the value of gender; i.e. either "male" or "female". The header can only have 1 heading. Could you please explain further if I have misunderstood? Thanks – PostureOfLearning Sep 12 '13 at 21:51
  • yeah it is a poor example of my data. I just wrote a pivot function that formats the data correctly. – theHaggis Oct 17 '13 at 10:39

2 Answers2

0

I'm not sure it's possible natively within the framework, but it looks like you can dynamically pass an array containing the column definitions to the table instance while creating it, so you could potentially handle it that way in javascript - you might want to check out this example.

How to create dynamic columns for Handsontable?

Old thread I know, but it's the first one that comes up for handsontable pivot table, so hopefully this helps someone.

grasmi
  • 199
  • 1
  • 6
-1

To set custom row/column headers, have a look here:

http://handsontable.com/demo/renderers_html.html#header

Portion from above page:

$container.handsontable({
  colHeaders: [
    "<b>Bold</b> and <em>Beautiful</em>",
    "Some <input type='checkbox' class='checker'> checkbox"
  ]
})
PostureOfLearning
  • 3,481
  • 3
  • 27
  • 44