• Resolved grokwhy

    (@grokwhy)


    I’m trying to get cell formating working using the Advanced Setting on the table builder,

    { “render”: “function(row, data, index) {return data === 1 ? ‘Yes’ : ‘No’;}” }

    The editor accepts the code, but no change on the front end.

    Any thoughts here? No errors appear in Chrome Dev Tools.
    Thanks,
    GrokWhy

Viewing 3 replies - 1 through 3 (of 3 total)
  • Leeberty

    (@aaronvincentlee)

    Hi @grokwhy ,

    I understand that your code isn’t working as intended. Let me help you with this.

    Can you please explain the behavior you want to achieve with your code? Perhaps an example page or basis for us to assess this better.

    We’ll wait for your reply.

    Thread Starter grokwhy

    (@grokwhy)

    @aaronvincentlee Thanks for getting back to me. Here’s a simple example. I’ve used Table Builder to create a table of toys. When the data is displayed in the grid, I’d like InStock to be displayed as Yes/No, and Cost to be displayed with a $.

    What do I add to Advanced Settings?

    Thanks!
    GrokWhy

    Leeberty

    (@aaronvincentlee)

    Hi @grokwhy ,

    You are most welcome!

    I’ve recreated your table and came up with a solution for you.

    Please try this code in the advanced settings:

    { 
    "fnRowCallback": "function(row, data, index) { if (data[2]=='1') { jQuery(row).find('td:eq(2)').html('Yes'); } else { jQuery(row).find('td:eq(2)').html('No')} }" 
    }

    For reference, see: More Complex JavaScript Functions | WP Data Access

    Your project should look something similar to this after. See video: https://share.getcloudapp.com/geuP9yO0

    I hope this helps.

    Let me know how it goes for you.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Table Cell Format’ is closed to new replies.