Any1 know how to sort a data table?

  • Chris4beh
  • Novice
  • Novice
  • Chris4beh
  • Posts: 18

Post 3+ Months Ago

On the internet just show how to sort before bind to gridview and etc

but I wan to sort the table to put the no for each row,anyone can help?

Then if got the column got same value,then how? For example:

Table
Column1 column2
a 7
b 3
c 3
d 5

need to sort by the column2
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

google search "order by"

For example
http://www.w3schools.com/sql/sql_orderby.asp
  • Chris4beh
  • Novice
  • Novice
  • Chris4beh
  • Posts: 18

Post 3+ Months Ago

you miss undestood alr,cos I am try to sort is datatable ,not sql component.
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

Perhaps you should specify what application you are using then, because it makes a difference. If you are using a web application then you sort the SQL/MySQL when creating the data grid. If you are using Access, Access has a built in sort function. I'm sorry I missunderstood what you wanted to know but it's because you weren't clear enough with your question.
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

The SQL if I understood you correctly

For Ascending
Code: [ Select ]
ALTER TABLE `table` ORDER BY `field`

For Descending
Code: [ Select ]
ALTER TABLE `table` ORDER BY `field` DESC

Where `field` is a primary key. (Not sure if it's necessary that field be a primary key. Doesn't work for me if it isn't).
  • neksus
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 2194
  • Loc: Canada

Post 3+ Months Ago

I don't think he's using SQL.
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

By "...not sql component." I think he means the "order by". He wants to change the order of the DATABASE and that SQL does just that. All you have to do is go on SQL in the table in phpMyAdmin.
  • sammehta
  • Born
  • Born
  • sammehta
  • Posts: 1

Post 3+ Months Ago

just fill the data in datatable...

then use
datatble.defaultview.sort = "column name";
  • hgun77
  • Graduate
  • Graduate
  • User avatar
  • Posts: 164
  • Loc: Malaysia

Post 3+ Months Ago

else you may try to use javascript, doing sorting in DOM.

Post Information

  • Total Posts in this topic: 9 posts
  • Users browsing this forum: No registered users and 77 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.