GithubHelp home page GithubHelp logo

Comments (7)

n1crack avatar n1crack commented on June 1, 2024

Can you change the last part and try again pls ?

from
order by laporan.status asc
to
order by status asc

from datatables.

rowjak avatar rowjak commented on June 1, 2024

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.

n1crack avatar n1crack commented on June 1, 2024

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.

rowjak avatar rowjak commented on June 1, 2024

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.

n1crack avatar n1crack commented on June 1, 2024

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.

rowjak avatar rowjak commented on June 1, 2024

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.

durango25 avatar durango25 commented on June 1, 2024

I have the same problem.

from datatables.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.