I have a column for decimal field values. I have set its format to #.#. So nothing shows when it a cell value is 0. This works great until one clear out all contents from the cell using Delete and tabs out of cell. That's when he gets the "value in editor is invalid" error message from Grid.
I am guessing there is some setting that would interpret a completely emptied out cell to mean "0". That way the system is happy with the numeric value and does not return the error.
Let me know the best way to to get around this problem.
Thanks!
I assume you mean MaskInput, not format. Format would have no effect when editing a cell.
Try using a MaskInput of "n.n" instead of "#.#", and that seems to work for me.
Mike,
The solution proposed did not work. I was previously using Format and not MaskInput. .Let me describe the problem again.
Requirement; We want the Grid to show only zero value cells as blanks. That keeps the grid from looking busy and helps users quickly notice the non-zero values. That was the reason for using a column format of #.#.
When I removed the Format of #.# and replaced it with MaskInput of "n.n", as you suggested, I ended up with 0's showing on cells that were previously blank.
Then I tried, using both Format as #.# and MaskInput as "n.n". That is no better.
As soon as I enter the blank cell i.e. a cell with 0 value, the cell goes into edit mode and shows 0.0. The left side picture shows you such a cell in edit mode.
Next, if user types a number in cell and tabs out, everything is fine.
However, if user clears out all contents of this cell by using delete key, then the cell shows "_._" shows due to the mask. You can see this on right side image.
If now user tabs out, I am guessing an invalid value is sent back and an an error shows. See image below.
You will notice that setting the format made the adjacent zero value cells are showing as blank because they is not in edit mode.
Desired behavior: Preserve the blank look of a zero value cell. When the delete clears out all values, make a 0 get saved back instead of the error.
.
Hi,
I don't think there's any way to stop the 0.0 from displaying once the cell goes into edit mode. 0 is, in fact, the value of the cell, so I don't see any way around that.
However... I tested this out using a MaskInput of "n.n" and a Format of "#.#" and I am able to blank out the contents of the cell and then leave the cell without any errors. So I'm not sure why that's not working for you.
My testing was done using v9.2 with the latest service release, so maybe you are using an older version and this is a bug that has since been fixed.
yes, this is good.
Well, if your data source does not allow nulls, then what are you expecting to happen when the cell is cleared?
Hi Mike,
I have tried it is not the problem of "n" and "#". If the DataColumn of the dataset allows DBNull, it will OK. When it doesn't allow DBNull, whatever you set the mask, you will get an error when clear everything in the cell and exit edit.
Again... if I use "n", instead of "#", this works fine for me. "#" is a required characters, so if you use that in your mask, you cannot leave it blank. "n" indicates a number section which can be left blank.
As I said above, if you are using "n", and it's not working, then something else is wrong there. It might be a bug in an old version of the controls (although this seems very unlikely). But it's definitely working for me in v9.2. So if this doesn't work, then either your application is not actually using the "n" (perhaps it's being overwritten by something else your code is doing) or it's a bug in the version you are using.
There is still a confusion about the problem statement.
Mike Saltzman said:I don't think there's any way to stop the 0.0 from displaying once the cell goes into edit mode. 0 is, in fact, the value of the cell, so I don't see any way around that.
In fact, I am okay with 0.0 showing when cell goes into edit mode. That is not a problem at all. Let me explain this way
If you review my previous post, you will see from my picture, the problem is when one tabs out of the cell (in edit mode) after completely clearing it out using delete.
We do not want the tab out to report this error I mentioned. And we want the underlying DataColumn to get a 0 value even though the cell was completely cleared out.