How to set conditions on what data will be displayed?

How to set conditions on what data will be displayed?

patreeeeekpatreeeeek Posts: 14Questions: 7Answers: 0

I have a datatable, data came from a json file.

It has a column as follows:

CONTACT_NO,CONTACT_NAME, CONTENT,DATE_RECEIVED

is there any way to do an if statement in rendering the data?

that if CONTACT_NAME is empty or null
the CONTACT_NO will be displayed else the CONTACT_NAME

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @patreeeeek ,

    You can use columns.render for that - the fifth example has something along the lines of what you want.

    Cheers,

    Colin

  • patreeeeekpatreeeeek Posts: 14Questions: 7Answers: 0

    Hi @colin ,

    { "mData": function (data, type, dataToSet) {
                                        if(data.contactName === null){
                                            return data.sender;
                                        }else{
                                            return data.contactName;
                                        }
                                    }
                         },
    

    I've done this one.
    My problem now is my datatable has too many data.
    Is there any way to load the datatable per page?

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @patreeeeek ,

    Yep, you can use serverSide for that - this page of the FAQ discusses several approaches to speed up the processing.

    Cheers,

    Colin

This discussion has been closed.