Comments (7)
I think it is not necessary.
You can add an option parameter to javascript to order any column you want.
https://datatables.net/reference/option/order
example :
$('#example').dataTable( {
"order": [[ 3, 'asc' ], [ 1, 'asc' ]]
} );
from datatables.
Btw, that default part works only if there is no header info. Datatables is sending the header info to sort first column as default
from datatables.
I know well datatables option, but I want to have initial order completely different. I can not make that kind of order with columns in datatable.
from datatables.
https://gist.github.com/n1crack/7467a9a991369cb44b1e4d6af4933ac2
I made some changes for you in this gist. let me know about the results. You must add "order": [] to your javascript.
Still when the user sorts the table via clicking columns, it will be ignored.
from datatables.
No it is not good. If I have in order by something like "case when c.data_type = 'STRING' then 1 else 0 end, c.column_name", than I got error Unknown column 'c.data_type' in 'order clause''.
My solution:
.....
$query = preg_replace("/((?:[^()]+|(?R))+)/i", "", $query);
preg_match_all("/SELECT([\s\S]?)((\s_)FROM(?![\s\S]_)))([\s\S]*?)/i", $query, $columns);
$columns = $this->explode(",", $columns[1][0]);
.....
....
if ( ! is_array($dtorders))
{
return $this->hasOrderIn?"":$orders . $this->columns[0] . " asc"; // default
}
....
from datatables.
Nice one. ty. This will be added in the next patch.
from datatables.
Thx
from datatables.
Related Issues (20)
- extender export button HOT 1
- adapter for eloquent
- update CI 3 example
- CI 3 with hooks error
- another eample
- empty dataset
- How to include in project without Composer
- Which method adds optional parameters to the row? HOT 1
- Multiple value coloumn order HOT 2
- Add support for Embedded DataTable from Editor HOT 1
- Conditional where clauses for PhalconAdapter HOT 1
- MySQL error on special column names HOT 5
- addIndexColumn / DT_RowIndex
- Laravel adapter does not work with PostgreSQL
- PhalconAdapter not working
- Export to Excel feature HOT 1
- datatable: data with function, doesn't work sort HOT 1
- Problem when using sql server in codeigniter 4 adapter HOT 2
- data as array are forbidden
- Skip Total Records HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from datatables.