Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#bad value# in an empty cell #1539

Closed
lafar6502 opened this issue Jun 22, 2014 · 33 comments
Closed

#bad value# in an empty cell #1539

lafar6502 opened this issue Jun 22, 2014 · 33 comments

Comments

@lafar6502
Copy link

Hi, there's a problem with checkbox columns. When an empty row is added to a table, it contains #bad value# in checkbox cells and you cannot change this value to anything else - the cell is read only, stuck with #bad value# in it. I'd like to specify some default value for a new row, but there's no way to do so.

Version: 0.10.5

@zorab47
Copy link

zorab47 commented Oct 17, 2014

I'm seeing the same issue on 0.11.4:

capture

See a running example here: http://jsfiddle.net/2xv3ojqa/

When minSpareRows is set and the table is empty then the checkbox column displays "#bad value#" for the initial row and all new rows. But that isn't the case when there is at least one existing row.

@warpech warpech added this to the 0.11.5 milestone Oct 20, 2014
@krzysztofspilka
Copy link
Member

Thanks for reporting! We'll try to fix this within milestone 0.11.5. Stay tuned!

@Berus
Copy link
Contributor

Berus commented Oct 28, 2014

@zorab47 try to add dataSchema: {car: null, year: null, comesInBlack: null} into your settings.

@jarben
Copy link

jarben commented Nov 5, 2014

Also happens when pressing delete on the checkbox cell..

@kevin-j-morse
Copy link

@Berus @zorab47 adding dataSchema: {name1: null, ... , nameN: null} solved this problem for me.

Thanks so much. I was really panicking for a second there!

@krzysztofspilka krzysztofspilka modified the milestones: 0.11.5, 0.12 Nov 13, 2014
@Berus Berus closed this as completed Nov 18, 2014
@kevin-j-morse
Copy link

Is this fixed? I don't see it in any milestones anymore?

@anoopkp06
Copy link

This issue still exists,

@rock1984
Copy link

Go to http://handsontable.com/demo/checkbox.html.
Click do Edit in jsFiddle.
Remove 'available: false' from some item in the getCarData function.
Run! the issue remains.

@bilalsoomro
Copy link

I am also experiencing the same error. When I my cell has a value inside and I change it's type, it displays a #bad value#. If the cell value is null, then it's fine.

@dgollub
Copy link

dgollub commented Apr 15, 2015

"#Bad value" also happens when you have an empty data set, ie. you are starting out with an empty table, that has only the columns and column headers predefined. This is in current master.

@ichiriac
Copy link

I also have the issue when I uncheck a checkbox and I use checkedTemplate and uncheckedTemplate.

You can try this jsfiddle :
http://jsfiddle.net/hzqobm5g/

@AMBudnik
Copy link
Contributor

Thanks for sharing @ichiriac I'm reopening this issue.

@AMBudnik AMBudnik reopened this May 27, 2016
@clo-dan
Copy link

clo-dan commented Jul 18, 2016

I have the same problem as ichiriac. If I use a checkedTemplate of 1 and an uncheckedTemplate of 0, I get #bad-value# when unchecking the box. Any workaround for this? I am using 0.26.0.

@mrpiotr-dev
Copy link
Contributor

It's problem with checkedTemplate/uncheckedTemplate.
short list of the problematic conversions:
numeric -> numeric = #bad-value#
numeric -> boolean = #bad-value#
boolean -> numeric = #bad-value#
string -> numeric = #bad-value#

@mrpiotr-dev mrpiotr-dev added this to the Backlog milestone Jul 21, 2016
@jansiegel jansiegel modified the milestones: 0.27.1, Backlog Sep 2, 2016
@mota57
Copy link

mota57 commented Sep 6, 2016

I try to set a checkbox by doing the following. Hot. GetCellMeta(0,0).type= "checkbox";. And i get #bad-value#

@AMBudnik
Copy link
Contributor

AMBudnik commented Sep 6, 2016

hi @mota57 I've tested this example here: http://jsfiddle.net/kt6racbp/ seems it works as expected

@ghost
Copy link

ghost commented Sep 6, 2016

@AMBudnik if you paste text or drag a cell to the cell with the checkbox you will get #bad-value#

@AMBudnik
Copy link
Contributor

AMBudnik commented Sep 6, 2016

Thanks for sharing details and your prompt reply Marc.
I've managed to reproduce the cell type change.
issue-hot-checkbox
The checkbox cell type is changing (copied) for the checkbox while it should stay the same (like for the date cell in the last row).

@ghost
Copy link

ghost commented Sep 6, 2016

I don't think it's the first time that this bug is reported no ?

@mota57
Copy link

mota57 commented Sep 6, 2016

@AMBudnik ok but what if you want to put a checkbox on the first cell of the first column. ? It said #bad-value#. So how to handle that ? test it yourself.!!

@mota57
Copy link

mota57 commented Sep 6, 2016

Hey I think I fix what I was saying. So your code should look like this and the default value would be "false". Test it!!!!.

...but now I have another problem after I save the sheet and reload the data all those columns that had checkbox now contain only values like true or false....instead of the proper checkbox.

hot1.getCellMeta(lastCoordinates.startRow, lastCoordinates.startColum).type ="checkbox";
hot1.setDataAtCell(0,0,false);
hot1.render();

@AMBudnik
Copy link
Contributor

AMBudnik commented Sep 7, 2016

Thanks for sharing additional details @mota57 Unfortunately it works like that when there's a bug all actions taken after produce even more bugs.
The issue is not yet reviewed so each tips are highly apperciated.

@AMBudnik
Copy link
Contributor

AMBudnik commented Sep 9, 2016

Thanks to our trusted user Chow we have managed to take one step towards understanding this bug.
Here's an updated demo: http://jsfiddle.net/xu8fbqmL/
The change was to set the boolean value for the column while initialization.

Still we can see that the checkbox is shifted
checkbox

@ghost
Copy link

ghost commented Sep 9, 2016

@AMBudnik I am sorry but if you copy paste text in the checkbox cell, the type is still changing with #bad-value#.
Try to copy the first cell containing "Mercedes A 160" and paste it in the checkbox cell.

Although I am not sure if your change aimed that issue in particular..

@AMBudnik
Copy link
Contributor

AMBudnik commented Sep 9, 2016

You're right @marc-antoinepelletier
Thank you for your prompt reply and effort to check the case.
I have a feeling that this can be related to this issue https://github.com/handsontable/dev-handsontable/issues/46

@jansiegel
Copy link
Member

@mota57 Let me make sure if I understand what you're trying to achieve. If you're trying to make the cell at (0,0) coordinates a checkbox, you'll need to either:

Take a look at this example: http://jsfiddle.net/js_ziggle/2enh673x/

Otherwise the checkbox renderer wouldn't know what to render.

Similarly to @marc-antoinepelletier example:

Try to copy the first cell containing "Mercedes A 160" and paste it in the checkbox cell.

How would the checkbox renderer know if "Mercedes A 160" translates to "checked" or "unchecked"? I wouldn't know either :)

@jansiegel
Copy link
Member

Oh, and the bug @AMBudnik found is probably caused by autofill moving the cell meta where it shouldn't, and it should be definitely fixed, but it's not connected with this isse.

@ghost
Copy link

ghost commented Sep 14, 2016

@jansiegel I assume the checkbox renderer would check the value passed the cell, and if it's not a default boolean or any other default checkbox value you assigned in the setting, it would check the value or do nothing no ?

I had to make a custom checkbox renderer to translate this behaviour, I figure that should be handle by default in Handsontable no ?

@jansiegel
Copy link
Member

jansiegel commented Sep 14, 2016

@marc-antoinepelletier I'm not sure what you mean by

it would check the value or do nothing

What the renderer does is checking if the cell value is the same as the one defined in the templates, and if there are none, check if the value is a boolean. If nothing passes that verification it displays #bad-value#, as it means the cell's value is not supported by the renderer.

@ghost
Copy link

ghost commented Sep 14, 2016

I meant it would check (true value) or leave the cell as it is without updating it. From what you are saying, the most logic way would be that nothing should happen to the checkbox cell at the end instead of displaying #bad-value# if the value doesn't correspond no ?

@jansiegel
Copy link
Member

@marc-antoinepelletier Ok, now I get it. Thanks for clarifying!

I think it's a good idea for a new feature - setting the allowInvalid property to false for the checkbox-typed cell would work just like you explained. The property is currently available for the autocomplete and date editors, but it would be also useful for the checkboxes.
I've created a new issue for this: #3755

@ghost
Copy link

ghost commented Sep 14, 2016

@jansiegel Awesome, Thanks ! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests