jquery-jsontotable icon indicating copy to clipboard operation
jquery-jsontotable copied to clipboard

First row missing?

Open ruiwei opened this issue 11 years ago • 8 comments

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

ruiwei avatar Aug 26 '14 15:08 ruiwei

Hi, @ruiwei.

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

jongha avatar Aug 27 '14 00:08 jongha

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".

ruiwei avatar Aug 27 '14 13:08 ruiwei

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

jordanstephens avatar Sep 17 '14 14:09 jordanstephens

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.

jordanstephens avatar Sep 17 '14 15:09 jordanstephens

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.

jongha avatar Sep 20 '14 05:09 jongha

+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!

ramotswa avatar Oct 14 '14 15:10 ramotswa

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

bartekbrak avatar Aug 14 '16 09:08 bartekbrak

@bartekbrak this solves the problem https://github.com/jongha/jquery-jsontotable/issues/6#issuecomment-55907953

ahmed-abdelazim avatar Aug 03 '20 13:08 ahmed-abdelazim