jongha/jquery-jsontotable

First row missing?

ruiwei opened this issue · 8 comments

The first row always missing.
Looks like the first row has been used for "Header" if "header: true".

Hi, @ruiwei.

Can I check your sample data?
Thank you for your report.

Data is standard JSON object. The first row of JSON always missing.
Looks like the first row has been used for "Header". (Line 123)

By the way, I do not use Table for display but only for Print. Google Chrome seems ignore "" on "@media print".

+1 on this—seeing the same behavior. I'll see if I can sort it out

The bug is here, https://github.com/jongha/jquery-jsontotable/blob/master/src/jquery.jsontotable.js#L123

I'm not sure what was originally intended here, but it needs to be solved another way.

  /**
  /* MODIFIED: options.header ? 1 : 0
  /* to eliminate duplicating header as the first row of data 
  **/
  for (i = (options.header ? 1 : 0); i < obj.length; i++) { 
    if (dictType && headerObj) {
      var bodyItem = {};

just set i = 0

for (i = 0; i < obj.length; i++) { 

I haven't looked at the rest of this code long enough to know why you really need that offset in the case that options.header == true, but if you really need it, there's probably a better way to do it.

Thank you for your valuable opinion. I'm late with my reply because I have been too busy with work recently. I'm sorry. I have checked what you addressed and have fully understood the problem. I agree with you and will try solving this issue as soon as I'm available. Thank you.

+1 from me..
I have this problem now too - like what you've done with it all but this seems to be an obvious problem!

+1
@jongha, it doesn't seem you're working on this code any more, please mark this in the README

@bartekbrak this solves the problem
#6 (comment)