webismymind / editablegrid

EditableGrid is an open source Javascript library aimed at turning HTML tables into advanced editable components. It focuses on simplicity: only a few lines of code are required to get your first table up and running.
http://www.editablegrid.net
Other
795 stars 272 forks source link

Make ID column default "DESC" sortable on page laod #174

Closed Samadhan1012 closed 7 years ago

Samadhan1012 commented 7 years ago

First of all thank you so much for the nice and fabulous table. I want to default sort "ID" column in descending order. How can I make this?

madsonl commented 7 years ago

The easiest way to do this would be to just have the original data inputted as desc.

Samadhan1012 commented 7 years ago

OK. But how as I add new recors, it will be final row in MySql too. Can you plz clarify me little bit? I want latest record to be displayed on first page and first row.

madsonl commented 7 years ago

The query which you use to pull the data use a order by [id if you have one] desc when putting in the data this will make the most recent record become the top ones.

MSIH commented 7 years ago

/**

use EditableGrid.sort(columnIndexOrName, descending, backOnFirstPage)

Samadhan1012 commented 7 years ago

Thanks for the comments. It's working when changed from ASC to DESC in loaddata.php: if ( isset($_GET['sort']) && $_GET['sort'] != "" ) $query .= " ORDER BY " . $_GET['sort'] . ( $_GET['asc'] == "0" ? " DESC " : "" );