Okay
  Public Ticket #2340712
How to customize cell contents
Closed

Comments

  • fangquans started the conversation

    Dear support,

    I have a broad question on how to customize cell contents. This includes font size, alignment, margins, paddings, text size, image size, text color, background color of each cell or row.

    Is there any documentation?? 

  •  2,572
    Aleksandar replied

    Hello fangquans

    Unfortunately, there isn't any documentation with detailed instructions on how you can do this, but if what you're looking for isn't found in "Settings/Color and font settings", you can do it with custom CSS.

    For example, you can add a Custom CSS Class to the column, which is meant to call on a class which you would define in Custom CSS field in main settings of wpDataTables.

    So, if you were to name the class "color1", you should go to main settings/Custom JS and CSS/Cusom CSS, and enter this:

    table.wpDataTable td.color1 {
    color: red !important;
    }

    For table headers, you can find the column name in the column settings:

    6037346968.png

    Then add the following CSS:

    .wpdt-c th.column-product {
    background-color: red !important;
    }

    My test table has columns "Name", "Product", "Date" and "Image", so my CSS would look like this:

    .wpdt-c th.column-name {
    background-color: gray !important;
    }
    .wpdt-c th.column-product {
    background-color: red !important;
    }
    .wpdt-c th.column-date {
    background-color: blue !important;
    }
    .wpdt-c th.column-image {
    background-color: wheat !important;
    }

    And the outcome would be:

    9987106445.png

    If you want to apply this to all tables, you can paste the CSS in Custom CSS field in Custom JS and CSS tab in main settings of wpDataTables. If, however, you wish to apply this only to a certain table on front-end, you need to add it when you're creating the page, above the shortcode, in between the <style>...</style> tags, like this:

    <style>
    .wpdt-c th.column-name {
    background-color: gray !important;
    }
    .wpdt-c th.column-product {
    background-color: red !important;
    }
    .wpdt-c th.column-date {
    background-color: blue !important;
    }
    .wpdt-c th.column-image {
    background-color: wheat !important;
    }
    </style>
    [wpdatatable id=1]
    

    Of course, you can add "color" instead of "backgroung-color" if you wish to change the font color.

    I hope this helps.

    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

  • fangquans replied

    HI Aleksandar,

    The color setting kind of works for me. Can you give an example of aligning the text?? I use the follow css, but it doesn't seem to work

    table.wpDataTable td{
      text-align: center;
    }
  •  2,572
    Aleksandar replied

    Hi again fangquans

    You can use the same class you used for the color.

    For example:

    table.wpDataTable td.color1 {
    color: red !important;
    text-align: center !important;
    }


    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