Allow Cancellation of DataTable OnEditComplete Event
I'm submitting a ... (check one with "x")
[ ] bug report => Search github for a similar issue or PR before submitting
[ X] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35
Current behavior It is not possible to cancel / stop the propagation of the Datatable OnEditComplete event.
Expected behavior Ability to cancel / stop propagation of the OnEditComplete event
Minimal reproduction of the problem with instructions
What is the motivation / use case for changing the behavior? Allow validation of inline edits in a data table, and in the case of invalid data, disallow the completion of the edit.
Please tell us about your environment: N/A
- Angular version: 4.0.X
- PrimeNG version: 4.0.X
- Browser: [all]
- Language: [all]
- Node (for AoT issues):
node --version= N/A
Sounds good but no idea how can we do it.
Would including the original native event in the PrimeNG event work? So then stopPropagation() or preventDefault() could then be called on the native event.
They are browser events, by the time they are called, ngModel has already written to the model. What we can try is writing to a dummy model and at browser events like blur, enter or else decide to write to actual model or not.
Originally I was only thinking of preventing the browser event, for example, so that the focus could be forced to remain on a field where invalid data had been entered. I'd not considered whether the ngModel binding needed to be prevented, but being able to prevent the ngModel write sounds good.
I don't think it is necessary to prevent writing to the model. If focus remains on the element that has the "issue", the user will be forced to fix it, or cancel it by hitting ESC key.
I can say this: as much as I want to use this library, I'm about to move on to another library. This is very fundamental to grid behaviour (ability to validate and keep focus if no pass). Wish I could jump in and help! I think exposing native preventDefault() is just right.
This would be great!
It really needs something, because as far as I can tell, there's no way to validate anything entered using an editable DataTable.
p-dataTable is deprecated and will be removed in favor of the new p-table (aka TurboTable) of 5.1.0 so closing the issue. Please try the new p-table once 5.1.0 is released.