Null Cells

Null Cells

DanOshDanOsh Posts: 37Questions: 11Answers: 1

I have a MySQL table with NULL in cells I do not have any data. DataTables Editor displays the table of NULL cells as empty, which I want.

However, when I add a new row, certain cell columns display "0". Also, if I click on a cell that has for example a "YY" (Ex. 2010) and remove it, I get a 0 instead of a blank cell. How can I keep those cells displaying blank if it is NULL?

Thanks

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin

    Sounds like the database might be configured with a default of 0 for those columns?

    Allan

  • DanOshDanOsh Posts: 37Questions: 11Answers: 1

    I checked. All columns except the Primary Key ("id") are set to NULL. Only the INT defined columns display the 0 when I empty out the cell in the Editor.

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin

    I would need a full dump of the SQL and the PHP + JS code you are using if that is possible to try and recreate the issue please.

    Allan

  • DanOshDanOsh Posts: 37Questions: 11Answers: 1

    Hi Allan,

    Here is the zip file of the SQL dump, php and html files and the respective js folders. I kept the path structure within the archive.
    http://www.skywateryachts.com/datatables_editor/boats_table.zip
    Thank you.

    Btw, is there a downloadable manual I can print out?

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Answer ✓

    Thanks.

    Coudl you try using the nullEmpty set formatter please:

    Field::inst( 'Price_Original')->setFormatter( 'Format::nullEmpty' )
    

    for example.

    That will have Editor write a null value to the database when an empty string is found. It looks like the database is writing 0 to the integer field for an empty string.

    Allan

  • DanOshDanOsh Posts: 37Questions: 11Answers: 1

    Thanks Allan, that did the trick. Any idea why the MySQL database/table is writing 0's in just the integer fields? Just for my info, no big deal now that I've got the fix.

    This has been all kind of tricky, I'm getting data in the form of a CSV file from another source. So I've had to tip toe through how I set the field values, importing and displaying.

    Thanks again.

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin

    Any idea why the MySQL database/table is writing 0's in just the integer fields?

    I suspect it is MySQL trying to be helpful, rather than throwing an error. It is "casting" (for lack of a better term) the empty string to be 00000000....

    Allan

This discussion has been closed.