How to set one column based if condition

How to set one column based if condition

simaRasimaRa Posts: 6Questions: 3Answers: 0

Hi everyone
I want to set value of one column based one condition
if (account_id=='-1)
{data: 'colleague_id', name: 'colleagues.fullname'},
else
{data: 'account_id', name: 'account.account_alias'},

I dont want to set it in controller beacuse its filtering makes error
Thanks

Answers

  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    Hi @simaRa ,

    You would do that in columns.render,

    Cheers,

    Colin

  • simaRasimaRa Posts: 6Questions: 3Answers: 0

    can you help me How can I do it
    In fact, I need to change the name of the column for filtering

    {
    data: 'account_id',
    render: function(data, type, row) {
    if (data=='-1') {
    name: 'account.account_alias'
    }
    else
    name:'colleagues.colleague_fullname'
    }
    },
    This is not working :(

  • tangerinetangerine Posts: 3,348Questions: 36Answers: 394

    Your render function needs to return a value.

This discussion has been closed.