sqlalchemy-datatables icon indicating copy to clipboard operation
sqlalchemy-datatables copied to clipboard

How to wary rendered column data according to condition?

Open lehtone1 opened this issue 2 years ago • 1 comments

I noticed that it is possible to do custom rendering for column with ColumnDT("<a href=''>" + User.id + "</a>"). How can I differ how the data is rendered according to a conditional? I would like to do something like this:

ColumnDT(
    if(User.id == 1):
        "<a href=''>" +  User.id + "</a>"
    else:
        User.id
)

lehtone1 avatar Oct 13 '21 14:10 lehtone1

Ok got it. Apparently you need to just do it with columnDefs

lehtone1 avatar Oct 14 '21 08:10 lehtone1