[CLOSED] Help in migrate this case from webform into MVC

  1. #1

    [CLOSED] Help in migrate this case from webform into MVC

    Can you help me how to migrate this "webform" case into "mvc"?

    a) In which event (controller) can I load the initial content of Combobox "cmbZ".
    b) I need when I click the Button "btnB" the "labels" being updated. At this moment, the labels are in the webform "runat" format. Can you help with the controller.

            <ul class="list-unstyled">
                    <li><strong>Ubicación:</strong> <ext:Label Id="lUbi" runat="server" /></li>
                    <li><strong>Director:</strong> <ext:Label Id="lDir" runat="server" /></li>
                    <li><strong>Administrador:</strong> <ext:Label Id="lAdm" runat="server" /></li>
                </ul>
    @model System.Collections.IEnumerable
    
    @{
        Layout = "~/Views/Shared/_Layout.cshtml";
    }
    
    @section extnetsection {
        @Html.X().ResourceManager()
    }
    <div class="breadcrumbs">
        <div class="container">
            <h1 class="pull-left">Directorio Unidad/Teléfono</h1>
            <ul class="pull-right breadcrumb">
                <li><a href='@Url.Action("Index", "Home", new { area = "Comun" })'>inicio</a></li>
                <li class="active">directorio</li>
            </ul>
        </div>
    </div>
    <div class="container">
        <div class="row">
            <div class="col-sm-2 md-margin-bottom-10">
                @(Html.X().ComboBox()
                    .ID("cmbZ")
                    .Editable(false)
                    .DisplayField("Descripcion")
                    .ValueField("Id")
                    .QueryMode(DataLoadMode.Local)
                    .TriggerAction(TriggerAction.All)
                    .EmptyText("Zona")
                    .Listeners(ls =>
                        ls.Select.Handler = "#{cmbU}.clearValue(); #{stU}.reload(); #{grdD}.getStore().removeAll();#{lUbi}.setText('');#{lDir}.setText('');#{lAdm}.setText('');"
                    )
                    .Store(Html.X.Store()
                        .Model(Html.X.Model()
                            .Fields(Html.X.ModelField().Name("Id").Type(ModelFieldType.String),
                                    Html.X.ModelField().Name("Descripcion").Type(ModelFieldType.String)
                            )
                        )
                        .Listeners(ls =>
                            ls.Load.Handler = "if(#{cmbZ}.store.getCount() > 1){#{cmbZ}.setValue(#{cmbZ}.store.getAt(0).get('Id')); #{cmbU}.getStore().reload(); #{grdD}.getStore().removeAll();#{lUbi}.setText('');#{lDir}.setText('');#{lAdm}.setText(''); };"
                        )
                   )
                )
            </div>
            <div class="col-sm-2 md-margin-bottom-10">
               @(Html.X().ComboBox()
                    .ID("cmbU")
                    .TypeAhead(true)
                    .QueryMode(DataLoadMode.Local)
                    .ForceSelection(true)
                    .TriggerAction(TriggerAction.All)
                    .DisplayField("Nombre")
                    .ValueField("Id")
                    .EmptyText("Unidades...")
                    .ValueNotFoundText("Unidades...")
                    .Listeners(ls =>
                        ls.Select.Handler = "#{btnB}.enable(); #{grdD}.getStore().removeAll();#{lUbi}.setText('');#{lDir}.setText('');#{lAdm}.setText('');"
                    )
                    .Store(Html.X.Store()
                        .ID("stU")
                        .AutoLoad(false)
                        .Model(Html.X.Model()
                            .IDProperty("Id")
                            .Fields(Html.X.ModelField().Name("Id").Type(ModelFieldType.String),
                                     Html.X.ModelField().Name("Nombre").Type(ModelFieldType.String)
                            )
                        )
                        .Proxy(Html.X().AjaxProxy()
                            .Url(Url.Action("UnidadRefresh", "Directorio", new { area = "Comun" }))
                            .Reader(Html.X().JsonReader().RootProperty("data"))
                        )
                        .Parameters(ps =>
                            ps.Add(new StoreParameter("zonaid", "#{cmbZ}.getValue()", ParameterMode.Raw))
                        )
                        .Listeners(ls =>
                            ls.Load.Handler = "if(#{cmbU}.store.getCount() > 1) {#{cmbU}.setValue(#{cmbU}.store.getAt(0).get('Id'));#{cmbU}.enable();} else {#{cmbU}.disable();#{btnB}.disable();} #{grdD}.getStore().removeAll();#{lUbi}.setText('');#{lDir}.setText('');#{lAdm}.setText('');"
                        )
                   )
                )
            </div>
            <div class="col-sm-2 md-margin-bottom-10">
                @(Html.X().Button()
                    .ID("btnB")
                    .Text("Buscar")
                    .Icon(Icon.Magnifier)
                    .Disabled(true)
                    .LoadingState(new ButtonLoadingState() { Text = "Espere..." })
                    .DirectEvents(de => {
                            de.Click.Action = Url.Action("GetUnidad", "Directorio", new { area = "Comun" }); 
                            de.Click.Failure = "Ext.MessageBox.alert('Error', 'Error Buscando Informacion. Intente de Nuevo.');";
                            de.Click.EventMask.ShowMask = true;
                            de.Click.EventMask.Target = MaskTarget.CustomTarget;
                            de.Click.EventMask.CustomTarget = "#{grdD}";
                        }
                    )
                )
            </div>
        </div>
        <div class="row height-350 margin-top-20">
            <div class="col-sm-3 md-margin-bottom-10">
                <h3>Información</h3>
                <ul class="list-unstyled">
                    <li><strong>Ubicación:</strong> <ext:Label Id="lUbi" runat="server" /></li>
                    <li><strong>Director:</strong> <ext:Label Id="lDir" runat="server" /></li>
                    <li><strong>Administrador:</strong> <ext:Label Id="lAdm" runat="server" /></li>
                </ul>
            </div>
            <div class="col-sm-7 md-margin-bottom-10">
                @(Html.X().GridPanel()
                        .ID("grdD")
                        .Width(600)
                        .Height(300)
                        .Store(Html.X().Store()
                            .ID("st01")
                            .Model(Html.X().Model()
                                .Fields(
                                    new ModelField("Area"),
                                    new ModelField("Telefono"),
                                    new ModelField("Comentario")
                                )
                            )
                            .DataSource(Model)
                        )
                        .ColumnModel(
                            Html.X().Column().ID("AreaColumn").Text("Area").DataIndex("Area").Flex(1),
                            Html.X().Column().ID("TelefonoColumn").Text("Telefono").DataIndex("Telefono"),
                            Html.X().Column().ID("ComentarioColumn").Text("Comentario").DataIndex("Comentario")
                        )
                        .View(Html.X().GridView().TrackOver(true).StripeRows(true))
                   )
            </div>
        </div>
    </div>
    Thanks in advance, being honest I'm coming into the MVC ext.net, any help is welcomed.
    Last edited by Daniil; Nov 25, 2015 at 4:13 PM. Reason: [CLOSED]
  2. #2
    Hi @rguardado,

    a) In which event (controller) can I load the initial content of Combobox "cmbZ".
    Please clarify how it was done in WebForms?

    I guess in Page_Load? If so, then please use a Store's DataSource in the View.
    Html.X.Store()
       .DataSource(data)
    You can populate directly in the View, but usually it is sent from a Controller action (the View's one) via ViewBag or ViewData or Model.

    b) I need when I click the Button "btnB" the "labels" being updated. At this moment, the labels are in the webform "runat" format. Can you help with the controller.
    Please start a new forum thread.

Similar Threads

  1. Reasons to migrate from 1.7 to 3.x
    By vadym.f in forum Open Discussions
    Replies: 4
    Last Post: Aug 11, 2015, 3:33 PM
  2. [CLOSED] Need ability to search combobox items by lower case or upper case
    By wisdomchuck in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jul 23, 2012, 1:40 PM
  3. ext.net 2.0 and webform
    By Akane in forum Open Discussions
    Replies: 1
    Last Post: Jun 06, 2012, 5:17 PM
  4. Migrate from Coolite 8.2.0 tp Ext 1.2.0
    By HzA in forum 1.x Help
    Replies: 2
    Last Post: Nov 15, 2011, 8:07 AM
  5. Ext.Net webform and Ext.Net MVC
    By wadhah in forum 1.x Help
    Replies: 0
    Last Post: Oct 25, 2011, 10:13 AM

Tags for this Thread

Posting Permissions