Ticket T593756
Visible to All Users

How to show a modal form using the DevExtreme framework

created 7 years ago

I have a form with various data fields …some of which I'd like to define as anchors to Modal Forms … to fill in detail for said object type ( for instance Underwriter shows up as a NAME on the main screen but clicking on it would bring up a modal form (fully functional) to edit the Underwriter info ( Location, experience level, notes, …)  … that modal form would function independently (it's own controller / calls) and return back to the main page to ask it to refresh (say in case the name was edited on the modal form ).

Can something like this be done with DevExtreeme popup … can they contain a full validated devextreme form instead of a simple message … can they call back or force a refresh on main page when they close ?

Thanks

Answers approved by DevExpress Support

created 7 years ago

Hi,

You can use the dxPopup widget for this purpose. Its shading option allows you to control whether or not the popup window should be modal. Put the dxForm widget into the popup container and use the validate method to perform validation. Handle the onHidden event to perform the required actions after the popup is hidden.

Thanks,
Alessandro

    Comments (3)

      AWESOME … I'm going to give this a go…

        @(Html.DevExtreme().Popup().HoverStateEnabled(false).ID("thePopUp").Shading(true).ShowCloseButton(true).ContentTemplate(@<text>
            <span id = "popupSpan">
                THIS IS THE POPUP
            </span>
         </text>)
        )

        Then I replaced the content of the popup with a partial (which is a dxForm for data entry).

        ODD:

        (1) the Form is too big for the popup but instead of adjusting to the scrren size … only first section of the form is visible.

        (2) when I hit submit on the popup  which has a PARTIAL of just the form, the popup CLOSES (I didn't ask for that) … and the PARTIAL's controller action is NOT called.   Popup just closes.

        (3) I thought of doing a dxScrollbar.Content(@<text> but couldn't use it because of nested @<text> not being allowed.
        So, How would I put somthing with a template (or content) withing another dxObject that also has a Template/Content method

        DevExpress Support Team 7 years ago

          Hi Brian,

          Let me answer you sequentially.
          1. If you do not have enough space, I suggest that you use the scroll view component and customize a form to occupy the whole space.
          2. As Alessandro mentioned, you need to handle the onHidden event in order to make a server side call to your controller. You can do it in the following way:

          JavaScript
          function onHiding(e) { $.ajax({ type: "POST", url: "TestForm/TestEx", async: "true", success: function (msg) { // On success }, Error: function (x, e) { // On Error } }); }
          ASPx
          Html.DevExtreme().Popup().ID("popup").Shading(true).OnHiding("onHiding")

          3. Am I right that you would like to add a scroll view and place the form inside? If so, you can add the ScrollView directly to a partial view. See the code below:

          ASPx
          Html.DevExtreme().Popup().ContentTemplate(@<text> <span id="popupSpan"> @(Html.Partial("~/Views/TestForm/TestForm.cshtml")) </span> </text>)
          ASPx
          @(Html.DevExtreme().ScrollView().ID("scrollView").ShowScrollbar(ShowScrollbarMode.Always).Content( @<text> <h2>TestForm</h2> @(Html.DevExtreme().Form() .ID("form") .ColCount(2) .FormData(Model) .LabelLocation(FormLabelLocation.Top) .MinColWidth(300) .ReadOnly(false) .ShowColonAfterLabel(true) ) </text> ))

          I hope you will find it useful.

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.