tabalinas / jsgrid

Lightweight Grid jQuery Plugin
http://js-grid.com
MIT License
1.52k stars 352 forks source link

Validating with ASYNCH API Call #283

Open ViniH opened 8 years ago

ViniH commented 8 years ago

Hi there, me again.

With regard to validation. Can you explain how I can handle a validation function that makes an ASYNCH API call that returns a promise to be fulfilled?

At the moment I am handling validation manually in the updateItem method, and adding a custom click handler to the cancel edit button that removes the error when the editing mode is cancelled. (For future versions it would be really useful to have a callback "onEditingCancelled" event to attach this sort of stuff to.

tabalinas commented 8 years ago

Currently validation is not supporting async checks, it's work in progress. Please, check out my answer on SO with a workaround http://stackoverflow.com/questions/36277981/how-can-i-check-the-inserted-edited-item-in-jsgrid-isnt-duplicate/36291243#36291243

ViniH commented 8 years ago

Thanks for this, I already had a workaround in place which involves manually setting/clearing error element.

The way I got round the lack of onEditingCancelled event was to attach the class removing method to the clickhandler for the cancel edit button. i.e.:

$( element ).find( ".jsgrid-cancel-edit-button" ).click( function () { $( element ).find( "tr.jsgrid-error" ).remove(); });

Not very elegant but it does the job.