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

bug in qx.ui.table.cellrenderer.Number #9340

Closed
dvoral opened this issue May 22, 2017 · 16 comments
Closed

bug in qx.ui.table.cellrenderer.Number #9340

dvoral opened this issue May 22, 2017 · 16 comments

Comments

@dvoral
Copy link
Contributor

dvoral commented May 22, 2017

If the cell is empty (null) and is being edited, then NaN displays.

From Derrell Lipman:
if (cellInfo.value || cellInfo.value == 0) {
should be
if (cellInfo.value || cellInfo.value === 0) {
Note the triple '=' so that it catches the number 0 but not something that's falsy like null.

We should also change the else condition where it says cellInfo.value == 0.

@johnspackman
Copy link
Member

Hi @dvoral, thanks for the bug report - could you try implementing a Pull Request with this change? That's the fastest way to get a fix integrated into the core

@derrell
Copy link
Member

derrell commented May 25, 2017

Sigh. There is no good solution to this problem.

On the one hand, we can change the format method of qx.util.format.NumberFormat so that an empty string is not NaN, but that is not backward compatible with apps that expect an empty string to return NaN.

We could also change qx.ui.table.cellrenderer.Number so that it does what its name implies and ensures that every field contains a number. This would mean that if the data is null or an empty string, we put a 0 in the cell. That way, the cell editor (which was the basis of the OP's problem for which this issue was created) would always get a valid initial value, and not display NaN. That is also not backbackward compatible, because programs may well expect the ability to have empty fields in a Number column.

I'm open to ideas.

Derrell

@zaucker
Copy link
Member

zaucker commented May 25, 2017 via email

@level420
Copy link
Member

@dvoral did you find a solution for this bug? Please share you're solution/thoughts. Thank you.

@dvoral
Copy link
Contributor Author

dvoral commented Jun 13, 2017 via email

@level420
Copy link
Member

@dvoral would you please be so kind to create a pull request for qx.ui.table.celleditor.TextField. that would be great! thank you!

@dvoral
Copy link
Contributor Author

dvoral commented Jun 13, 2017 via email

@derrell
Copy link
Member

derrell commented Jun 13, 2017

I'd suggest adding this as a static function numberOrWhitespace (or some such thing) in the cell renderer, so that it would be easy to just do something like

intEditor.setValidationFunction(intEditor.constructor.numberOrWhitespace)

@level420
Copy link
Member

level420 commented Jun 13, 2017

@dvoral there are several tutorials out there but here a short version which works completely in the browser:

  • Create a fork of qooxdoo master (the button called fork on the top right of this page). This creates a fork of qooxdoo master under your account called dvoral/qooxdoo (https://github.com/dvoral/qooxdoo)
  • go to repo dvoral/qooxdoo and navigate in the source tree to framework/source/class/qx/ui/table/celleditor/TextField.js
  • on the top right of the source code view there is a pencil icon. click it to open the file in edit mode
  • make your changes and add comments if needed
  • save the changes (there is a button below of the editor). you will be asked if you want to save it in master or in some branch. choose the branch and name it e.g. with the issue # in the name, something like dvorak-fix-9340
  • after sucessfully saving navigate to the master branch of your qooxdoo fork (https://github.com/dvoral/qooxdoo)
  • you'll note a green "create pull request" button which, if clicked, offers you to create a PR which is a patch against qooxdoo/qooxdo master based on your changes in dvorak/qooxoo/

That's it.

Try it! You could do no harm to the original repo. We won't let you :-)

@dvoral
Copy link
Contributor Author

dvoral commented Jun 14, 2017

Thanks for your detailed instructions. I've made the pull request.

@johnspackman
Copy link
Member

johnspackman commented Jun 14, 2017 via email

@level420
Copy link
Member

level420 commented Jun 14, 2017

@dvoral you created the PR from dvoral/qooxdoo:dvoral-fix-9340 against your own fork master dvoral/qooxdoo:master

Please navigate again to https://github.com/dvoral/qooxdoo/pulls to the PR list and then click the green button "New pull request".

There will appear four buttons for selection on the "Comparing changes" page.

Please select there from the rightmost button (Text beginning with "compare:") the dvoral-fix-9340 branch. This way you compare your branch against qooxdoo/qooxdoo:master.

You will then be offered again the "Create pull request" green button which allows you to publish your PR in https://github.com/qooxdoo/qooxdoo/pulls

@dvoral
Copy link
Contributor Author

dvoral commented Jun 14, 2017 via email

@level420
Copy link
Member

@dvoral if you need to add changes to the PR or change your current PR, you simply navigate to the corresponding branch https://github.com/dvoral/qooxdoo/tree/dvoral-fix-9340 and edit what you want and save to the same branch (here dvoral-fix-9340).

As soon as you've done that, the changes appear in the PR #9348

@dvoral
Copy link
Contributor Author

dvoral commented Jun 15, 2017 via email

@level420
Copy link
Member

Fixed via #9348

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

5 participants