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 7005183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:19:09+00:00 2026-05-27T21:19:09+00:00

I am displaying the database table values using data tables. I am doing this

  • 0

I am displaying the database table values using data tables. I am doing this using the ajax method. Here is the code

$('#example1').dataTable( {
                "bProcessing": true,
                "sAjaxSource": "filename.php",
                "bJQueryUI": true,
                "sPaginationType": "full_numbers"

            } );

The output of the filename.php is

{ "aaData": [["1","<input type='checkbox' name='user'>&nbsp;Test Name","Leader","35"]] } 

The html code is

<table cellpadding="0" cellspacing="0" border="0" class="display tablehead" id="example1">
              <thead>
                  <tr class="colhead newbg">
                    <th width="17" align="center">No</th>
                    <th width="194" align="left">User</th>
                    <th width="56" align="left">Role</th>
                    <th width="31" align="right">AGE</th>  
                  </tr>
                  </thead>
                    <tbody>

                    </tbody>
              </table>

In the above html you can see the first column is center aligned and the next two columns are left aligned and the last one is right aligned. But in the data out put all are center aligned. I tried to use the following

{ "aaData": [["<div align='center'>1</div>","<div align='left'><input type='checkbox' name='user'>&nbsp;Test Name</div>","<div align='center'>Leader</div>","<div align='right'>35</div>"]] } 

Now i got the correct display but while sorting by age it is not correct. Please help. Thanks

  • 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-27T21:19:10+00:00Added an answer on May 27, 2026 at 9:19 pm

    I think you should do something like (use aoColumns):

    $('#example1').dataTable( {
                    "bProcessing": true,
                    "sAjaxSource": "filename.php",
                    "bJQueryUI": true,
                    "sPaginationType": "full_numbers",
                "aoColumns": [ 
                            {"sClass": "center"},
                            {"sClass": "left"},
                            {"sClass": "left"},
                            {"sClass": "right"},
    
                } );
    

    And then define the correct CSS classes

    .right{
      align: right;
    }
    
    .left{
      align: left;
    }
    
    .center{
      align: center;
    }
    

    In this way datatables handles appending the classes to the elements and the sorting works correctly. Of course use the first JSON

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

Sidebar

Related Questions

I am displaying values from database table using h:datatable, one tupple is displaying in
I am retrieving values from a database and displaying it a table using php.
I'm using a pagination method for displaying search results returned from my database. I'm
I have a table displaying results from a database, and I am adding some
I am displaying all values in table formated View: <div style=clear:both; padding-top:1px;>&nbsp;</div> <%if @signals[0]!=nil
I want to take the values from this site for the country table in
I am trying to display from a MySQL Database using PHP and Ajax but
I have a web page and using php Im quering a database and displaying
I have a MSSQL database table I'm accessing on a PHP page. I'm displaying
I am displaying the contacts on the table. Section I pass in the method

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.