Okay
  Public Ticket #3753121
Define a checkbox for true/false status
Open

Comments

  • Victor Hugo Calderón González started the conversation

    Hi

    I want to define a column to store a boolean value (tinyInt). Is it possible to show a checkbox and enable/disable it according to the stored value. Also to show this checkbox when edit or create a new register. Appreciate your help

  •  1,846
    Miloš replied

    Hi Victor,

    I am not sure I understood this use-case.

    If you mean to try a true boolean configuration directly from our Plugin :

    Sorry to disappoint you on this, but, since it is not possible to have true boolean values in the source SQL Database Table, our Plugin can only do "Conditional Formatting" to transform your 'final cell value' , for example from 0 to 'false', and from 1 to 'true';

    like this, in my example, i tried making an SQL Table in the Database that contains a "tinyint" Field and set 0 and 1 as possible values;

    Then in my Table, i can place two Conditional Rules :

    - If any cell value is 0, transform this cell content to show as "false";

    - or if it is 1 , transform to 'true';

    but this works only in the table cells -  

     for a CheckBox filter , or during Editing - our Plugin will show the actual value exactly as it is coming from the source Data/  0  or 1.

    1581541475.png
    8252987473.png
    8602672020.png
    9158229126.png
    3269125700.png

    So, at this time, the only way to have "true" or "false" show as possible filter or editor value, is to have them like that coming from your Source Data.

    This is an interesting idea for a future option, though,  so you can make a development suggestion, i just can't say an ETA if or when something like that might be possible for filtering/editing values.

    Please feel free to search on our suggestions page

     to see if someone may be already suggested this feature. If you can't see it, feel free to add your suggestion there,  and as more people vote, the feature will move higher on the priority list.

    You can certainly follow our changeLog page if you'd like ( it is also available in the plugin dashboard), where we state any changes/new features/bug fixes during updates;

    and our newsletter, so you're informed about new features, bug fixes, freebies, etc.

    -

    If you have coding skills and wish to try to make a custom solution now,

    you can check out our available hooks for Developers on this documentation and see if you can find any hook that might help.

    Please be advised that custom solutions with hooks are not included in our support.

    You can also research resources such as Stack Overflow to see if any other user perhaps found a workaround.

    ( We do like to give examples for certain solutions, but for this use-case, we, unfortunately, don't have anything yet)

     

    2. When it comes to showing a checkbox depending from the value, like 'if it is '1', then set a green checkmark symbol', we have an example how you can do this :

    If you wish to make a condition that checks for any cell that has value as "1" and to change the content of this cell to a green check symbol,  there is a solution.

    First, add a Conditional Rule to a column you need for this.

    Then you can add the content that will transform the cell if the condition is met.

     

    Perhaps the easiest way is to get an image of a symbol you need, upload it to the Media Library ( or you can use an image URL from somewhere else),

    and you can add custom HTML with the image tag to show the image in the cell.

    For example, if you wish to copy this same image of a green checker symbol as on this example "Amazon products table", you can use this HTML:

    <img src="https://wpdatatables.com/wp-content/uploads/2021/07/icon-yes.png" class="aligncenter size-thumbnail lazyloaded" width="20" height="20">
    

    And the green checker symbol should look like this in the table cell(s) :

    2626394647.png

    I made a small example on a table.  if i want to do this on the ID column for my table here :

    6820496362.png

    I will add this Condition to the Column ID :

    8458911777.png

    -

    And the cell that had value 1 turns out like this :

    9410463706.png

    Just to note, that example was with one of our own image URLs - for your table, you will need to provide your own image source, of course.

    Or you can use advanced HTML and CSS, like we did on a table, for example :
    <div class="checkmark" style="    display: inline-block;
        transform: rotate(45deg);
        height: 16px;
        width: 10px;
        border-bottom: 7px solid #78b13f;
        border-right: 7px solid #78b13f;"></div>

    Let me know if that works for your use-case.

     

    Thank you.

    Kind Regards, 

    Miloš Jovanović
    [email protected]

    Rate my support

    Try our FREE mapping plugin! MapSVG - easy Google maps, interactive SVG maps and floor plans, choropleth maps and much more - https://wordpress.org/plugins/mapsvg-lite-interactive-vector-maps/

    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