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

  • SEARCH
  • Home
  • 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 6203993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:00:47+00:00 2026-05-24T05:00:47+00:00

I have the following code to convert my JSON dataset to html table. I

  • 0

I have the following code to convert my JSON dataset to html table.
I want to know if it is the fastest method, or should I use jqote2 with jquery to write template?

Requirements:

  • can change col definitions with a click (client can change how to view table, col definition array will change, and table can be rebuilt)
  • sorting, filter & pagination (I believe raw data can be sorted and table can be rebuilt)
  • conversions (If say 1 col contains data of length in different units, than a new col in raw data set can be added having data in 1 same unit so that data can be sorted)

So can somebody guide me if I am on right track or am I working on something that already exists?

<div id="hii"><!-- table loads here --></div>

<script>
var set1={ // JSON dataset & col definitions
    'col':[ // definition/template of data to load in column cells
        [function(x){return '<a href="?sid='+x[1]+'">'+x[0]+'</a>';}],
        [function(x){return '<a href="?id='+x[2]+'">'+x[2]+'</a>';}],
    ],
    'data':[ // raw data, output table has only 2cells/row using these 3 values from each row
        ['Name 1','00000001','Value 1'],
        ['Name 2','00000002','Value 2'],
        ['Name 3','00000003','Value 3'],
        ['Name 4','00000004','Value 4'],
        ['Name 1','00000001','Value 5'],
        ['Name 5','00000005','Value 1'],
        ['Name 6','00000006','Value 1'],
        ['Name 7','00000007','Value 2'],
        ['Name 8','00000008','Value 6'],
        ['Name 9','00000009','Value 3'],
        ['Name A','00000010','Value 7'],
        ['Name B','00000011','Value 7'],
        ['Name C','00000012','Value 1'],
    ],
};
function tbody(x){ // function to create table, using dataset name passed to x
    for(i=0,data='';i<x.data.length;i++){
        data+='<tr>';
        for(j=0;j<x.col.length;j++){
            data+='<td>'+x.col[j][0](x.data[i])+'</td>';
        }
        data+='</tr>';
    }
    return data;
}
document.getElementById('hii').innerHTML='<table>'+tbody(set1)+'</table>';
</script>
  • 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-24T05:00:47+00:00Added an answer on May 24, 2026 at 5:00 am

    You can use Datatables. It works with jQuery and is also themable. There are quite a few options you can set that can meet your requirements, and even more.

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

Sidebar

Related Questions

I have the following code in Ruby. I want to convert this code into
I have the following code to convert a distinguishedName to a sAMAccountName: Dim de
I'm using php and I have the following code to convert an absolute path
I have the following code that is meant to convert milliseconds into hours, mins
I have the following FORTRAN code which I need to convert to C or
I have the following JavaScript code which I like to convert to jQuery but
I have the following code IDictionary<string, IEnumerable<Control>> I need to convert it to IDictionary<string,
I want to directly convert a javascript object to string. I used following code.
I have a JSON String like this $test='{var1:null,var3:null,status:{code:150,message:blah blah}}'; I want to access the
I have the following working code to convert a list with nested maps (actually

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.