Ajax - if, else (Help)

Ajax - if, else (Help)

TurksEmperorTurksEmperor Posts: 6Questions: 2Answers: 0

I want to hide the blank rows in my table, is there a way around this?
like my code. You have your help.

    var table;
    $(document).ready(function () {
        // DataTable
        table = $('#TabloBeklemede').DataTable({
            
            "processing": true,
            "serverSide": true,
            "ajax": {
                "url": "/Personelizin/DynamicTable/",
                "type": "POST"
            },

            "columns": [
                {
                    "data": "IZIN_ONAY_DURUM",
                    "render": function (data, type, row) {
                        if (row.IZIN_ONAY_DURUM === 0) { return row.IZIN_ONAY_DURUM; }
                        else { return ""; }

                    }
                },
                {
                    "data": "AD_SOYAD",
                    "render": function (data, type, row) {
                        if (row.IZIN_ONAY_DURUM === 0) { return row.AD_SOYAD; }
                        else { return ""; }
                    }
                },
                {
                    "data": "IZIN_BASLAMA_TARIHI",
                    "render": function (data, type, row) {
                        if (row.IZIN_ONAY_DURUM === 0) { return moment(row.IZIN_BASLAMA_TARIHI).format('DD.MM.YYYY'); }
                        else { return ""; }
                        
                    }
                }
            ]
        });
      
    });

This question has an accepted answers - jump to answer

Answers

  • tangerinetangerine Posts: 3,143Questions: 27Answers: 366

    Why not have your server-side not return blank rows? I don't understand how you are seeing blanks.

  • colincolin Posts: 12,889Questions: 0Answers: 2,198
    Answer ✓

    As @tangerine said, it would be best to tackle this in the server-side script to reduce the traffic being sent. If you can't, this example may help, it's showing how to remove duplicate rows, so the same principles would apply for your empty rows,

    Colin

  • TurksEmperorTurksEmperor Posts: 6Questions: 2Answers: 0

    The example worked. Thank you for your help.
    @colin @mandalina

Sign In or Register to comment.