-
Notifications
You must be signed in to change notification settings - Fork 426
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
Prevent cell content removal on click (when editor is used) #11
Comments
From your description of the problem, I suspect that you don't understand how the editors work. I have embedded full jQueryUI controls as editors, so there's no problem with complex editor contents. |
Well, if my description is not clear I will explain here again: As in attached image, I have requirement to clear the inputs (range) only when user click on the clear button (red circled). I understood the concept of formatter (how to render the value) and the editor (what to do on click), the problem what I'm talking about is how to prevent the content getting clear on click?. Before the editor init function get called the content is getting cleared. To be more specific in the
How to set the parameter |
What I mean is that to keep it simple, you should write a formatter/editor pair that conforms to the normal behaviour of the grid editors. See example3a-compound-editors.html for a perfectly good range editor.
by setting |
OK, I've decided the best way to do this is to add a property
edit: see comments below, the above is WRONG and should be:
I've then made
These changes have just been added to the repo here. Let me know if it works for you. |
This will not work because the variable "suppressClearOnEdit" is a property of the editor function and we can get access to it only if we call (new instance of) the function. At this point the we haven't called the editor method so it will be undefined (not exposed). The simplest and easiest way to solve this problem is by add property ("suppressClearOnEdit") to the column definition rather to trying to access the method property. |
Sorry, you are correct that the code as-is will not work. My bad.
I did consider the column property, but I still think this is a better approach, because the behaviour is part of the editor, and might be used in multiple columns, or columns might have editors dynamically reassigned. |
I don't see the side effects of adding a variable to the column definition, its more flexible then your approach. Your suggestion will fails if we define the editor as anonymous function. |
I just think philosophically the behaviour is part of the editor, not the column. The only connection with the column is that the editor happens to have been assigned to it, and I want to avoid creating more 'noise' in the column defaults if at all possible. It would fail if the editor were anonymous, but why would you want to do that ? |
In my opinion: Its not part of editor but column definition, why? answer is simple, the editor is reusable component, the same editor can be in more than one column but each column may have different behaviors. It is not always true that the default operation (empty the cell) to be prevented in all columns the editor is used. So I believe that adding it as column definition (config) is the best solution. In my case, I use anonymous function (as editor) in case if no reusable code and not required complex logic. Like simple inline editing (just example - We can use the one comes with editor but can't customize it to our needs). Unless a proper solution closing the ticket is not a good sign. |
Look I'm sorry but I don't agree with any of these points. So again, sorry, this is not a problem I have with you. As the gatekeeper for this project, consistency and simplicity are really important as they affect maintainability of the code, especially in team environments. It's easy to let requirements for flexibility turn the API into a hotchpotch of methods, when it's often better to make things slightly less flexible but architected in a way that promotes consistent program structure. |
That is okay and thanks, I have already forked to go my way. |
Hello,
I have custom editor for cell, the problem i'm facing is whenever the cell is clicked the existing content (DOM) is getting removed and also I'm not able to listen to the events registered to the cell content DOM. Is there way I can prevent the cell content removed by default? how do I listen to the cell content DOM events?
In the attached image, the 2 input boxes must show on clicking "Set Range" and if user click on the clear icon (red x circled) the cell content should set back to "Set Range". I have implemented using "grid.onClick.subscribe" but this have other challenges like validation. I couldn't use the editor because of the cell content getting cleared by default.
The text was updated successfully, but these errors were encountered: