ASP.net
Awesome
Learn
Forum
Buy
Demos
Sign In
☾
☀
Switch to
Dark
Light
Mode
this site works best with javascript enabled
Ask Question
preventDefault in awebeginload
Title:
B
I
{code}
?
Hello, I want to validate a search form and load related grid only if validation is successed. Something like this: $myGrid.on('awebeginload', function (event, requestData) { if ($myForm.valid()) { // push search params to requestData } else { event.preventDefault(); // doesn't work } }); How can I stop the grid from loading?
Save Changes
Cancel
tsv
asked at 15 Nov 2016
Answers
B
I
{code}
?
I'm guessing you're using `.Parent` to bind the form controls to the grid, you could instead on search click use grid's api and call `api.load({ params: { Name: 'Foo', Par1: $('#id').val(), ... })` or you could use `.DataFunc("searchFunc")` instead of `.Url`, and do the validation on the client: function searchFunc(g) { // validate here; you may use var gp = utils.getGridParams(g) if you want, or validate $('#id').val() directly if(!valid){ return null; } return $.post('@Url.Action("GetItems", "LunchGrid")', g).then(function(model) { return model; }); }
Save Changes
Cancel
Omu
answered at 15 Nov 2016
Second solution was helpfull, thank you
at 15 Nov 2016
tsv
please
Sign In
to leave an answer
By accessing this site, you agree to store cookies on your device and disclose information in accordance with our
cookie policy
and
privacy policy
.
OK