Multiple Submit Buttons

Hi

I have a usual CRUD with the edit in the dialog. I have the usual Save button which closes the dialog. However, I also want to have another button that also does a Submit but doesn't close the dialog.

Is there a way to determine which button was click to Submit the TemplateForm?

Hi @kirank ,

Maybe you can do this:

Thanks you.

I tried that already. Using the click event means the validation controls on the page don't work.

I have 2 buttons which are both set to ButtonType="ButtonType.Submit". If I use the click event on one of the pages, the click fires eventhough there are validation controls on the form that are not satisfied. The button without the click event fires the validation controls and the code for Submit="@Form0Submit" only if validation is satisfied.

Is there a way to set value="SaveAndClose" and have this available in the Form0Submit backend code?

You can create two properties and assign them in the Click handlers of the buttons. Then check their values in the Submit event handler of the form and act accordingly. You can probably do that with a single boolean property.

Hi @korchev

That worked like a charm. I created a single property SaveAndClose and set it to true in one button and false in another. I didn't realise the Submit event ran afterwards anyway if the buttons were of type Submit.

Thank you. Much appreciated.

Regards
Kiran

Hi @korchev

One thing I noticed is that if a TemplateForm has a Tab, the validation controls only fire on the tab that I'm currently viewing. If I have a required validation on another tab and it isn't completed, the required validator doesn't fire.

Don't know if this is something that can be looked at.

Regards
Kiran

This is by design. Even if validation fired the validators won't be visible to the end user in the other tab. You can probably try setting RenderMode to Client which should cause the validators to trigger but they won't show still.

Thank @korchev

As the validation is on a separate tab, no seeing the validation message is understandable but the concern is that if no validation, the record can be saved without the validation defeating the purpose of the validation.

Is there any side effects of setting the RenderMode to Client that I eed to be aware of and test/

Regards
Kiran

The side effect is that all components in all tabs will render. In server rendering mode only the components from the current page render.

It would be cool to have a RadzenSubmitButton that does that automatically. The TemplateForm can have all the RadzenSubmitButtons of the form using a CascadeParameter. When a RadzenSubmitButton is pressed, it transparently set a SelectedSumitButton in the form, and in the form submit event, it gets the SelectedSubmitButton and calls the handler of the RadzenSubmitButton.

Hi,

I've created the 2 buttons and that works. However the 'InvalidSubmit' is triggered after the regular submit buttons. Hence no validations takes place before the Save/Delete. Any suggestions?