I can't stop event propagation from the editCellEnding event. In the event a user enters something other than a number, I show them an alert and want the focus to remain on the current cell, and it to stay in edit mode. If I try this and enter an invalid value and tab away, then the alert is shown but the focus is moved to the next cell and it enters edit mode. I've tried stopPropagation, stopImmediatePropagation, preventDefault and just returning false but nothing seems to stop it.
editCellEnding: function (evt, ui) { if(ui.value!='' && isNaN(ui.value)){ alert('Not a valid scoring number'); evt.stopPropagation(); evt.stopImmediatePropagation(); evt.preventDefault(); return false; }
Hi Chris,It seems to me that the checks you are performing are not sufficient to capture the fact that if the cell is left empty, its actual value is NULL.Also, if you're editing a number-valued column, our igNumericEditor ensures that the user can enter only numbers (no funny business).Thus, here's the code I can suggest:
editCellEnding: function (evt, ui) { if(ui.value === "" || !ui.value) { alert('Not a valid scoring number'); evt.stopPropagation(); evt.stopImmediatePropagation(); evt.preventDefault(); return false; } return true; },
PS: Check are based on the suggested answers from SO (http://stackoverflow.com/questions/154059/what-is-the-best-way-to-check-for-an-empty-string-in-javascript)
That was just code to try to get the event to stop and focus to remain in the current cell. The values can be an empty string (the default that was coming from the json data or a number the user entered - which is why I was checking and allowing either an empty string (if the user entered edit and left without changing anything) or a false from isNaN. Thanks for the info on the igNumericEditor though.
The code was being executed and going all the way to the return false statement (having tried each of the previous statements by themselves and together as well) but the propagation didn't stop and the focus was moved to the next cell as a result of the tabbing/hitting enter/etc...
How can I stop the event from continuing and keep the focus in the current cell?
Hi Chris,The only way I can think of is to rely on editor validation instead of the editCellEnding event. Can you give the the following configuration of the Updating feature a go?
{ name: 'Updating', editMode: 'cell', enableAddRow: false, enableDeleteRow: false, columnSettings: [ { columnKey: "J5", required: true, validatorOptions: { keepFocus: true } } ] }
Please let me know if works for you or not (fingers crossed that it does! :)).PS: It might seem like a stretch to define a column setting for each one of your number-valued columns, but with some clever array manipulation you can iterate through the array of the grid's columns and generate an Updating columnSettings array object. PPS: The fact that the the editCell* events do not honor the presence of hidden cells has been logged as a development issue with ID #117141 which will soon be associated with a CASE bound to this forum thread.
Hello Chris,
Thank you for your reply and feedback. We appreciate that you took the time to convey your comments and I assure you that we consider our customer community comments very important to steering improvement at Infragistics.
Should you still decide to try the igGrid, please do not hesitate to contact us for support.
Hi Borislav,
I appreciate that. Unfortunately I didn't have the time to wait, and it seemed like everyday I was bumping my head against at least one shortcoming or issue of the igGrid for a couple of weeks, multiple ones of which got entered as bugs for the next service release. I was able to take jsViews, build my table template dynamically for it, apply the Editable library, jQuery Sorting & Pagination, add new rows and complete the task in under 3 days. I was even able to add my own custom keyboard navigation in that timeframe (tab at end of row goes down to next row first editable cell, down arrow/enter move down and start next column at end, etc... )
Maybe I'll try igGrid again sometime, but I can't waste any more time on it currently and not again until it's a bit more robust (and more fully documented). Thanks again though.
~Chris
Hi Chris,After discussing development issue #117141 with our developers it turned out that I was wrong - the column index is correct in the editCell* events - so I admit that I got a bit hasty in submitting that.About the sample I promised you - it's doable with in row editing mode, because the rowEditEnding event has an input param called ui.keepEditing - it allows the editor of the cell to remain instead of jumping to the next cell. Our developers will add this param to the editCellEnding event for the next Service Release so hopefully then (about a month from now) we'll have have a better out-of-the-box solution for you.All the best,Borislav
Hi Chris,
revbones said:My issue isn't really validation but in trying to cancel the event and keep the focus in that cell.
revbones said:I'm confused regarding the hidden column you mentioned in your PPS statement. While there is a hidden cell in the grid, the cell that I was editting is not hidden.
Hello revbones,
Thank you for your reply. After further research we have asked our engineers to examine this issue further. To ensure that it will receive attention, this behavior has been logged in our internal tracking system with a Development ID of 117141. The next step will be for a developer to review the work item and offer a fix or some other resolution.
Your support ticket regarding this matter CAS-96041-77JYGD. Feel free to continue sending us updates to this case at any time.
You can view the status of the development issue connected to this case by selecting the "Development Issues" tab when viewing this case on the web site.
Please let me know if you need more information.