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

Editor doesn't left align on numbers which are left-aligned #119

Open
dsl101 opened this issue Apr 1, 2016 · 0 comments
Open

Editor doesn't left align on numbers which are left-aligned #119

dsl101 opened this issue Apr 1, 2016 · 0 comments

Comments

@dsl101
Copy link

dsl101 commented Apr 1, 2016

Sorry, I know this should probably be a pull request, but I just made a fix locally (not in a repo), and the patch is small, so I thought I'd post it here in case it helps.

The specific case is that I wanted numbers to be left aligned like everything else, so I changed the css like this:

td.number {
    text-align: left;
}

But the editor seems hard-coded to assume numbers are right-aligned, and so it opens in the wrong place. I fixed editablegrid_editors.js by putting a guard around the right-alignment code to check the element style is actually right aligned like this:

@@ -148,9 +148,11 @@

        // if number type: align field and its content to the right
        if (this.column.datatype == 'integer' || this.column.datatype == 'double') {
-           var rightPadding = this.editablegrid.getCellX(element) - offsetScrollX + element.offsetWidth - (parseInt(editorInput.style.left) + editorInput.offsetWidth);
-           editorInput.style.left = (parseInt(editorInput.style.left) + rightPadding) + "px";
-           editorInput.style.textAlign = "right";
+           if(window.getComputedStyle(element, null).getPropertyValue("text-align") == "right") {
+               var rightPadding = this.editablegrid.getCellX(element) - offsetScrollX + element.offsetWidth - (parseInt(editorInput.style.left) + editorInput.offsetWidth);
+               editorInput.style.left = (parseInt(editorInput.style.left) + rightPadding) + "px";
+               editorInput.style.textAlign = "right";
+           }
        }
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant