question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

is it possible to access values in nested data? i have [ { fields: { systemWorkItemType: "Feature", systemState: "New", systemReason: "New", systemTitle: "initial work item", systemBoardColumn: "New", systemBoardColumnDone: false, microsoftVSTSCommonStateChangeDate: "2016-12-07T14:02:24.24Z", microsoftVSTSCommonPriority: 2, microsoftVSTSCommonValueArea: "Business", microsoftVSTSCommonRisk: "3 - Low", weF_8107056482E145ECA07BC00173CF6A70_KanbanColumn: "New", weF_8107056482E145ECA07BC00173CF6A70_KanbanColumnDone: false, systemDescription: "a test description" }, id: 2, relations: [ ], rev: 4 } ]

im trying to add the field values into the table but neither "fields[“systemState”] or fields.systemState work? id and rev come out fine… e.g. column { title: "Name", field: "fields.systemTitle", sorter: "string", sortable: true }, any ideas?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
olifolkerdcommented, Jul 23, 2017

Hey,

You will be happy to hear that Tabulator 3.2 has just been released, and with it the the ability to bind columns to nested data, simply use dot notation in the field name:

{title:"age", field:"user.age"), //link column to age property inside user object

Full information can be found in the Column Definition Documentation

Cheers

Oli

1reaction
JeremyMorelcommented, Mar 16, 2017

One item to note for anyone wishing to use the function Oli has provided to “flatten” their data structure: There were two typos, which I have corrected in this version.
flatternRow should read flattenRow, and the line var flat = flattenData(row[prop]); should instead be var flat = flattenData(row[prop]);, else the function will fail at the foreach clause when it reaches the first nested object. Hopefully it saves someone a few cycles around the debugger! 😃

//flatten data

function flattenData(data){
	var output = [];
	function flatternRow(row){
		var outputRow = {};
		for(var prop in row){
			if(typeof row[prop] !== "object"){
				outputRow[prop] = row[prop];
			}else{
				var flat = flattenRow(row[prop]);
				for(var flatProp in flat){
					outputRow[prop + "_" + flatProp] = flat[flatProp];
				}
			}
		}
		return outputRow;
	}
	data.forEach(function(row){
		output.push(flatternRow(row));
	});
	return output;
}

//load data into table
$("#example-table").tabulator("setData", flattenData(data));
Read more comments on GitHub >

github_iconTop Results From Across the Web

Nested data
A nested data frame is a data frame where one (or more) columns is a list of data frames. You can create simple...
Read more >
How to work with Nested Data - Medium
In the field of Data Science or Business Intelligence, one often comes into contact with nested data, for example when working with data ......
Read more >
Analyzing Nested (Clustered) Data | Center for Large ... - UTMB
Most large data sets that can be used for rehabilitation-related research contain data that are inherently 'nested' or 'clustered.' Persons who see the...
Read more >
Analyzing Nested Data (Chapter 32)
As a general definition, nested data exists whenever multiple observations are sampled from each of multiple units. The data then consist of two...
Read more >
Nested and Repeated Data - Kaggle
In this tutorial, you'll learn how to query nested and repeated data. These are the most complex data types that you can find...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found