Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6111615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:39:02+00:00 2026-05-23T14:39:02+00:00

JSON Structure: {rows: [ {row:[ {cells: [ {data: Edit}, {data: 030194}, ]} ]}, {row:[

  • 0

JSON Structure:

{“rows”: [

 {"row":[ 
      {"cells": [
     {"data": "Edit"},
     {"data": "030194"},

      ]}
 ]},
 {"row":[
      {"cells": [
     {"data": "Add"},
     {"data": "030194"},
      ]}
 ]},
 {"row":[
      {"cells": [
     {"data": "Delete"},
     {"data": "030194"},
      ]}
 ]}           

]}

JQuery code:

$.each(response.rows, function(index, rows){

 $.each(rows.row, function(index,row){ 
      var element=$("tbody").append("<tr id='" + index + "'>");  
      var element1=element.append("<td><input type='checkbox'></input></td>");
      $.each(this.cells, function(index){ 
           element1.append("<td>" + this.data + "</td>"); 
      });
      $("tbody").append("</tr>"); 
 });  

});

Problems:

  1. Each row generated has an ID with value of index = 0. The ID for Row1 should be 0, for Row2 it should be 1 and for Row3 ID should be equal to 2

  2. td elements are drawn out as children of tbody. They should be children of tr

  3. closing tr should be drawn after the last cell in each row, currently the tr closes itself before any cell is drawn

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T14:39:03+00:00Added an answer on May 23, 2026 at 2:39 pm

    Try this. This stumped me for a bit, because I was used to the syntax of .each() in the context of looping through DOM elements. Since it’s $.each(), the index of the first loop refers to the number you were trying to get for every row.

    I moved the TR append outside the loop you had it in.

    (Last-child isn’t the fastest method of adding the TDs, you could use createElement like Endophage posted, and then refer to that)

    http://jsfiddle.net/EY4an/

    $.each(response.rows, function(index, rows) {
    
        $("tbody").append('<tr id="index' + index + '"></tr>');
    
        $.each(this.row, function(index) {
            var element1 = $("tbody tr:last-child").append("<td><input type='checkbox'></input></td>");
            $.each(this.cells, function(index) {
                element1.append("<td>" + this.data + "</td>");
            });
        });
    });
    

    I also added the word ‘index’ to the ID attributes on the table rows, because IDs are supposed to start with a letter.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a set of data in one JSON structure: [[task1, 10, 99], [task2,
I've got the following JSON structure that defines a table and it's data. var
JSON structure: { codes:[ { id:1, code:{ fname:S, lname:K } }, { id:2, code:{
I'm trying to consume a WCF webservice using jQuery. The returned Json data is:
I'm having trouble in parsing my JSON data in jQuery autocomplete. My JSON comes
I have the following JSON structure : { codes:[ { id:1, code:{ fname:S, lname:K
I have the following JSON structure: [{ id:10, class: child-of-9 }, { id: 11,
I'd like to create a tree structure from JSON, but with multiple columns that
I have two JSON objects with the same structure and I want to concat
I need to transform my nested sets structure (mysql) into json for this spacetree

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.