Okay
  Public Ticket #1938199
Zero on empty integer-cells
Closed

Comments

  • KienbaumIT started the conversation

    Some integer cells in my table will be empty, where the data isn't available. At the moment, the table is showing these as a zero value (0). It's better if these show as an empty cell.

    But please don't let the cells show any content, even if no value was entered, right? There are series of salary numbers entered, and some of them are not yet available - if a 0 is output there, this is more than bad. I do not want to change the field type in order not to lose the 1000 separator. It also prevents users from entering anything other than numbers

    How can we fix that?


  •  2,572
    Aleksandar replied

    Hello KienbaumIT.

    I'd like to know if you're going to calculate any averages in that column?

    If not - this should be easily fixable. When you click on column settings, go to Conditional Formatting. There you can enter a rule:

    9274981108.png

    So, when a 0 is found in the cell, it'll just lose it and display a blank cell:

    9921775767.png

     Or, you can add a dash, like this:

    6100871057.png

    So it looks like this:

    2180326327.png

    Basically, this only impacts the AVG and MIN calculation of the column; SUM and MAX will still remain unchanged.

    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

  • KienbaumIT replied

    Thanks, yes - this is an solution, but it don't works for me, because zero IS an information. But i don't want to place it automatically by the system. The user should be allowed to set the value to 0 - but the system should not set the value by itself ...  With your solution nobody can place zero value ...

  •  2,572
    Aleksandar replied

    Hello again KienbaumIT.

    It took some time, but I believe we found a temporary solution for you. Please note that this hasn't been thoroughly tested, so I can't guarantee that it'll work in all instances.

    Please open ../wp-content/wpdatatables/controllers/wdt-ajax-actions.php and search for this around line 357:

    $formData[$column->orig_header] = WDTTools::wrapQuotes((float)$formData[$column->orig_header], $tableData->connection);
       if ($formData[$column->orig_header] == '') {
       $formData[$column->orig_header] = NULL;
       }
       break;
     case 'int':
       $formData[$column->orig_header] = WDTTools::wrapQuotes((int)$formData[$column->orig_header], $tableData->connection);
       if ($formData[$column->orig_header] == '') {
       $formData[$column->orig_header] = NULL;
    }

    Please delete "(float)" and "(int)" so it looks like this:

    $formData[$column->orig_header] = WDTTools::wrapQuotes($formData[$column->orig_header], $tableData->connection);
       if ($formData[$column->orig_header] == '') {
       $formData[$column->orig_header] = NULL;
       }
       break;
     case 'int':
       $formData[$column->orig_header] = WDTTools::wrapQuotes($formData[$column->orig_header], $tableData->connection);
       if ($formData[$column->orig_header] == '') {
       $formData[$column->orig_header] = NULL;
    }
    

    That should keep the empty values without adding the zero there.

    Please try this and let me know if it 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

  • KienbaumIT replied

    Hi Aleksandar,

    It worked for me, thank you very much! Do I have to make this change manually, or will it be fixed in an upcoming update?

    Kind regards,

    Florian

  •  2,572
    Aleksandar replied

    Hi again Florian.

    I don't know if it will be implemented in the next update, but it most definitely will in one of the future ones. One of our developers has started working on an even better solution for it, so it should be an included feature in the future.

    Until then, please save this reply because you will need to do it again if it's not included in the next update.

    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