Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First row missing? #6

Open
ruiwei opened this issue Aug 26, 2014 · 8 comments
Open

First row missing? #6

ruiwei opened this issue Aug 26, 2014 · 8 comments

Comments

@ruiwei
Copy link

ruiwei commented Aug 26, 2014

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

@jongha
Copy link
Owner

jongha commented Aug 27, 2014

Hi, @ruiwei.

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

@ruiwei
Copy link
Author

ruiwei commented Aug 27, 2014

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

@jordanstephens
Copy link

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

@jordanstephens
Copy link

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.

@jongha
Copy link
Owner

jongha commented Sep 20, 2014

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.

@ramotswa
Copy link

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

grpgrp added a commit to grpgrp/jquery-jsontotable that referenced this issue Jan 14, 2016
Apply fix for missing first row of every table if headers:true

Per jongha#6
@bartekbrak
Copy link

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

@ahmed-abdelazim
Copy link

@bartekbrak this solves the problem
#6 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants