[CLOSED] Validate FormPanel and Save It using DirectMethods using MVC

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    [CLOSED] Validate FormPanel and Save It using DirectMethods using MVC

    Hi,

    I have the piece of code below and I want to Save the form using Direct Methods and MVC but I try many samples and nothing seems to work. Could you help me? Please provide and MVC sample on how to save forms and validate it both on client and server side.
    Another thing, can I update the Status bar from serve side instead of using Ext.Msg.Show() as I'm using in my controller? If yes, How can I do that.

    I notices that there are many examples using Web Forms and just a few using MVC. Even the examples page is much more complete for web forms than for MVC. Is there any good source of material for MVC Ext.NET aside from https://examples2.ext.net/ ?
    Thank you very much

    Here's the code:

    x.Panel()
                .Title("Dados Paciente")
                .AutoScroll(true)
                .Border(false)
                .Items(
                    x.FormPanel()
                        .ID("frmPaciente")
                        .Border(false)
                        .Layout(LayoutType.Fit)
                        .FieldDefaults(fd =>
                            {
                                fd.LabelAlign = LabelAlign.Left;
                                fd.MsgTarget = MessageTarget.Side;
                                fd.InvalidText = "Obrigat?rio";
                                fd.EnforceMaxLength = true;
                                fd.AutoFitErrors = true;
                                //fd.AllowBlank = false;
                                fd.SelectOnFocus = true;
                                fd.LabelWidth = 150;
                            })
                        .ItemsFromPartial("_DadosPaciente", Model.PacienteModel)
                )
                .Buttons(
                    x.Button()
                        .Icon(Icon.Erase)
                        .Text("Limpar Campos")
                        .OnClientClick("this.up('frmPaciente').getForm().reset();"),
                    x.Button()
                        .Icon(Icon.DatabaseSave)
                        .Text("Pr?ximo Passo")
                        .ID("btnSave")
                        .FormBind(true)
                        .Type(ButtonType.Submit)
                        .CausesValidation(true)
                        .DirectEvents(de =>
                        {
                            de.Click.Before = "return #{frmPaciente}.getForm().isValid();";
                            de.Click.Success = "#{DirectMethods}.SavePaciente()";
                        })
                        //.OnClientClick("return #{frmPaciente}.isValid();")
                        //.DirectClickAction("Save", "Paciente")
                ).Border(true),
    Here's the controller code:
    [DirectMethod]
            public ActionResult Save(PacienteModel paciente)
            {
                X.Msg.Show(new MessageBoxConfig
                {
                    Message = "Salvando Paciente, aguarde...",
                    ProgressText = "Salvando...",
                    Width = 300,
                    Wait = true,
                    WaitConfig = new WaitConfig { Interval = 200 },
                    IconCls = "ext-mb-download",
                    AnimEl = this.GetCmp<Button>("btnSave").ClientID,
                });
    
                X.AddScript("setTimeout(function () { Ext.MessageBox.hide(); Sucesso('pnlDadosPessoais','Paciente salvo com sucesso!','Informa??o'); }, 4000);");
    
                return this.Direct();
            }
    Last edited by Daniil; Mar 19, 2014 at 8:50 AM. Reason: [CLOSED]

Similar Threads

  1. Replies: 3
    Last Post: Jun 11, 2013, 4:48 AM
  2. [CLOSED] How to load FormPanel data using DirectMethods
    By jchau in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Sep 18, 2012, 10:53 AM
  3. [CLOSED] Save FormPanel fields after Confirm Message
    By Digital.Dynamics in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: May 10, 2012, 6:31 AM
  4. Replies: 12
    Last Post: Feb 20, 2012, 1:58 PM
  5. Replies: 1
    Last Post: Jul 27, 2011, 10:19 AM

Tags for this Thread

Posting Permissions