View Full Version : [CLOSED] before ajax request

Aug 19, 2014, 2:57 AM
Hi, I try to use batch grid update as below. I need to some data validation before call ajax. should I use de.click.before ()? what should JS fun return if I wan to cancel the ajax call ?


..Button ..

.Handler ("SaveGridDataChanges(this.up('grid'))")
.DirectEvents(de =>
de.Click.Url = Url.Action("SaveGridDataChanges", "Grid", new {gridID = Model.GridID});
de.Click.Before = "ValidateSave(this.up('grid'))";
de.Click.Confirmation.ConfirmRequest = true;
de.Click.Confirmation.Title="Save ?";
de.Click.Confirmation.Message =" Are you sure you want to save changes?";
de.Click.ExtraParams.Add(new Parameter
Name = "data",
Value = "this.up('grid').store.getChangedData({skipIdForPha ntomRecords : false})",
Mode = ParameterMode.Raw,
Encode = true
de.Click.Success = "onSaveSucess (this.up('grid'))";

Aug 19, 2014, 5:35 AM
Hi @susanz,

Returning false from a DirectEvent's Before handler prevents that DirectEvent.

So, you can do the following:

de.Click.Before = "return ValidateSave(this.up('grid'))";

And return true or false from the ValidateSave function.

Aug 19, 2014, 3:42 PM
Thanks you so much. It works.