Okay
  Public Ticket #2102174
Is it possible to display a calculated field in-line?
Closed

Comments

  • Robert started the conversation

    Is it possible to display a calculated field value in the body of a text without the "Max ="? 

    For example, if I add this to the body of text on a page: 

        "There have been an average [wpdatatable_max table_id=7 col_id=97] conflicts per day."

    I would like for it to display like this:

       "There have been 2.35 conflicts per day."

    But it shows up like this: 

        There have been

        Avg = 2.35
        conflicts per day.


  •  2,572
    Aleksandar replied

    Hello Robert.

    There's no way of doing this with plugin's built-in features, but it can be achieved with some CSS.

    Here's how it used to look on my page:

    5219306772.png

    And this is after applying CSS:

    3107679399.png

    And this is what happens:

    "There have been an average" is stored like this:

    6197019466.png

    So, you have to right click on the <p> go to Copy/Copy Selector, which comes back with this:

    #post-10 > div > p:nth-child(2)
    

    Then, we move to "Avg =". You'll see this:

    2774486699.png

    Right-click on "wdt-column-avg" Copy/Copy Selector. I got this:

    #post-10 > div > div > strong
    

    Also, you will have to use the wdt-column-avg to get it to display inline.

    After that, move to "Conflicts per day" which has a <br> before it:

    9526410576.png

    Right click Copy/Copy selector:

    #post-10 > div > br
    

    So, the final output would be:

    <style>
    #post-10 > div > div > strong {
    display: none !important;
    }
    #post-10 > div > br {
    display: none !important;
    }
    #post-10 > div > p:nth-child(2) {
    display: inline !important;
    }
    .wdt-column-avg {
    display: inline-block !important;
    }
    </style>
    There have been an average [wpdatatable_avg table_id=1 col_id=1]
    conflicts per day.
    

    I hope this helps.

    Best regards.

    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables