PHP libraries - Custom column ( not in database )

PHP libraries - Custom column ( not in database )

cr1st1cr1st1 Posts: 14Questions: 5Answers: 0
edited August 2019 in Free community support

I'm using PHP libraries and i need a custom column that is not in the database

For example : a table has columns C1, C2
I need a custom column B that is created using C1 and C2

i am using this solution now :

Field::inst( 'C1'),
Field::inst( 'C2'),
Field::inst( 'C1', 'B')
    ->set( false )
    ->getFormatter( function ( $val, $data ) { ...custom code ... }),

so i am reusing one of the existing columns (C1 in this example) and name it B
and also ->set( false )

Is there a better way to do this ?

This question has accepted answers - jump to:

Answers

  • colincolin Posts: 15,112Questions: 1Answers: 2,583
    Answer ✓

    Hi @cr1st1 ,

    This example should help - I think it's doing what you're looking for,

    Cheers,

    Colin

  • cr1st1cr1st1 Posts: 14Questions: 5Answers: 0

    Thank you @colin,
    this is a solution if you want to create the custom column on the javascript side but unfortunately i need to create the custom column on the server side, on PHP side.

    Do you have a solution using DataTables PHP libraries ?

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin
    Answer ✓

    The solution you have above is the best way of doing it if you want it done in PHP. However, personally I would suggest that you use a client-side data renderer if the server-side needs to know nothing about that column (i.e. its purely a client-side construct).

    What what we do for the Name column in this example.

    Allan

This discussion has been closed.