Jspdf-autotable: How to get `dataKey` from object

Created on 18 Apr 2016  路  8Comments  路  Source: simonbengtsson/jsPDF-AutoTable

var columns = [
  {title: 'Test', 'dataKey': 'address.test'}
  // ...
];

var data = [
  {address: {test: 'value'}},
  {address: {test: 'value 2'}},
];
question

All 8 comments

I'm not sure what you mean. Could you provide more details?

@simonbengtsson I want get address.test value in data object.

Or do a map @marioidival

var exportData = data.map(function(item){
return item.address;
});
var columns = [
  {title: 'Test', 'dataKey': 'test'}
  // ...
];

Where do you want to get adress.test?

By the way, {title: 'Test', 'dataKey': 'address.test'} will match var data = [{'address.test': {test: 'value'}}].

@simonbengtsson will match var data = [{'address': {test: 'value'}}] ???

Nope it matches what I posted above. You would have to flatten your object before passing it to the plugin.

If you are still having problems, let me know!

I've utilized @Purush0th's suggestion to a good effect. Thats the way to go if you happen to have a situation where you have nested object property which you have to use as the dataKey.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dnlbaldwin picture dnlbaldwin  路  6Comments

webdream-fr picture webdream-fr  路  6Comments

simonbengtsson picture simonbengtsson  路  4Comments

bsparacino picture bsparacino  路  3Comments

JoakFlores picture JoakFlores  路  3Comments