Wouldn't it be nicer to make the default format an object of arrays rather than an array of objects?
In before "but gzip!"
11–20 of 33 posts
Wouldn't it be nicer to make the default format an object of arrays rather than an array of objects?
In before "but gzip!"
It's a nice start to something that looks pretty useful. There are some things to consider though: What if you have headings as the first column in each row? What if you have headings in the first column, and the first row? Also, what is the use case for data overrides? In my opinion, it completely defeats the purpose when your intention is to take the contents of the table.
The code does not try to be clever: var getHeadings = function(table) { var firstRow = table.find("tr:first").first(); return notNull(opts.headings) ? opts.headings : rowValues(firstRow); }; The code is also going to fall down if you have things like wide/high cells. But HTML tables are so flexible and so routinely abused, I guess the problem is too hard to be solved robustly with any generality.
table.find('thead tr').children('th,td')
But it could easily be something like: var headings = table.find('thead th');
if (!headings.length) headings = table.find('th');
if (!headings.length) headings = table.find('tr:first td');The non-webdev part of me is rather depressed that we've resorted to storing N typically homogeneous records in a way which results in the serialization of field names N times. Wouldn't it be nicer to make the default format an object of arrays rather than an array of objects? In before "but gzip!"
I'm not trying to sound harsh, I just don't understand when I'd ever need to do something like this.
I'm having a hard time understanding why everyone's jazzed about this. When is this a useful thing to do? I've literally never once encountered a problem where this would be useful. I'm not trying to sound harsh, I just don't understand when I'd ever need to do something like this.
The non-webdev part of me is rather depressed that we've resorted to storing N typically homogeneous records in a way which results in the serialization of field names N times. Wouldn't it be nicer to make the default format an object of arrays rather than an array of objects? In before "but gzip!"
Awesome. Something else that would be nice is to be able to go from JSON to HTML table. There are a few libraries out there that do this but none seem to be updated or recent. Any suggestions would be greatly appreciated. Nice work!
Earlier quoted context omitted.
The code does not try to be clever: var getHeadings = function(table) { var firstRow = table.find("tr:first").first(); return notNull(opts.headings) ? opts.headings : rowValues(firstRow); }; The code is also going to fall down if you have things like wide/high cells. But HTML tables are so flexible and so routinely abused, I guess the problem is too hard to be solved robustly with any generality.
You could do what they're suggesting without being too clever. For instance, our dynatable plugin does it this way: table.find('thead tr').children('th,td') But it could easily be something like: var headings = table.find('thead th'); if (!headings.length) headings = table.find('th'); if (!headings.length) headings = table.find('tr:first td');
http://www.whatwg.org/specs/web-apps/current-work/multipage/...
This was developed with reference to a corpus of real web tables.