Comments (7)
Can you change the last part and try again pls ?
from
order by laporan.status asc
to
order by status asc
from datatables.
i've change to order by status asc
. but it doesn't work... the column ordering is stil order by first column i select ( pelapor.nik
)
from datatables.
You can set default ordering in the javascript options by doing:
”order”: [[ 3, “desc” ]]
See details here: https://datatables.net/examples/basic_init/table_sorting.html
If there is an error alert, can you share the console logs with me?
from datatables.
oke thanks it's work when i'm ordering using datatables javascript... but, i think it's should be great if i can ordering by sql select..
here is my full code
$datatables = new Datatables(new CodeigniterAdapter);
$datatables->query('SELECT pelapor.nik, pelapor.nama_lengkap, kategori.kategori, laporan.id, laporan.isi_laporan, laporan.lokasi_kejadian, laporan.latlng, laporan.status, laporan.disposisi, opd.nama_opd, laporan.tgl_input FROM laporan join kategori on kategori.id=laporan.kategori join pelapor on pelapor.nik=laporan.nik left join opd on opd.id=laporan.disposisi order by laporan.status asc');
```
$datatables->hide('id');
$datatables->hide('latlng');
$datatables->hide('tgl_input');
$datatables->hide('disposisi');
$datatables->edit('status', function($data){
if ($data['status'] == '0') {
return '<span class="badge badge-default">Belum Diproses</span>';
}else if ($data['status'] == '1') {
return '<span class="badge badge-info">Terverifikasi</span>';
}else if ($data['status'] == '2') {
return '<span class="badge badge-warning">Ditindaklanjuti</span>';
}else {
return '<span class="badge badge-success">Selesai</span>';
}
});
$datatables->add('action', function ($data) {
return '<button class="btn btn-secondary" onclick="detail_laporan(`'.$data['id'].'`)"><i class="fa fa-info"></i> Detail</button> <a class="btn btn-danger" href="javascript:;" onclick="hapus_laporan('.$data['id'].')" role="button"><i class="fa fa-trash"></i> Hapus</a>';
});
echo $datatables->generate();
from datatables.
if you are going to leave sorting to sql, still you should set the order option as an empty array:
"order": []
Do you get any errors ?
from datatables.
if i'm set "order" : []
in datatables javascript instead of "order" : [[5, "asc"]]
, order by columns not working and i don't get any error. It's still order by first column I select in sql
from datatables.
I have the same problem.
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.