ASP.net
Awesome
Learn
Forum
Buy
Demos
Sign In
☾
☀
Switch to
Dark
Light
Mode
this site works best with javascript enabled
Ask Question
How to disable grid/dropdown auto postback
Title:
B
I
{code}
?
I have a grid in a popup form. The form uses the default Ok/Cancel buttons. When I click a row in the grid and change an option in the .AjaxDropdownFor, a postback automatically occurs once I click off the row. I would like to disable the automatic postback and only do a postback when the user clicks the Ok button. Is this possible? Also, is it possible to change a grid's default loading from POST to GET? Thanks
Save Changes
Cancel
stevec50
asked at 19 Aug 2019
you could change it to get but why do you need that ? are you sure you're not triggering submit on the `form` from your custom js ?
at 19 Aug 2019
Omu
We have requirements that postbacks occur only when the user has updated all of the dropdowns in the grid and then clicks the Ok button. The postback is happening when the user changes the dropdown selection and then clicks off the row. There is no custom js for this form or grid.
at 19 Aug 2019
stevec50
"clicks off the row", does that mean you are using Grid with Inline Editing and `rowClickEdit` option true ?; can you put the grid outside of the `<form>` tag, just for experiment
at 19 Aug 2019
Omu
Correct, rowClickEdit: true. I have tried putting the grid outside of the form and removing the form altogether to see if there was a change in behavior but the postback is still occurring either way.
at 19 Aug 2019
stevec50
We've created a small demo using code from the master detail demos, you can download it here: https://files.fm/u/hsgxnmds in it you can see how grid inline editing works inside popupform, it is using AjaxDropdown, you can also change it to odropdown
at 19 Aug 2019
Omu
Thanks for the reply. However, in the demo the postback to the controller is still being triggered when the grid row is clicked off, and the controller action updates the database. This is the very behavior we need to avoid. We want the user to be able to change their dropdown selections for all grid rows without posting back to the controller until the user clicks the OK button. It doesn't sound like this is possible using the grid?
at 19 Aug 2019
stevec50
After doing some experimentation, I think the way to achieve this is to remove the .InlineEdit() completely and render an unbound <select> using ClientFormatFunc, then bind the <select> independently after the grid loads.
at 19 Aug 2019
stevec50
yes, this is by design, when you click save on the row or exit the row with `rowClickEdit` it will post to the url, if it updates the database that's already up to you. maybe you need something like this: https://demo.aspnetawesome.com/ListBinding
at 19 Aug 2019
Omu
Answers
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