[CLOSED] MVC3 Editor Template

  1. #1

    [CLOSED] MVC3 Editor Template

    I am trying to create an editor template and need a little help. Here is my code:

    @modelType  Models.LookUp
    
    @code
        If Model IsNot Nothing Then
            Html.X.ComboBox().ValueField("DataValueField").DisplayField("DataTextField") _
                .QueryMode(DataLoadMode.Local) _
                .Store(Sub(action)
                               action.Add(Html.X.Store().DataSource(Model.Options) _
                                          .Model(Sub(mdl)
                                                         mdl.Add(Html.X.Model().Fields(Sub(flds)
                                                                                               flds.Add("DataTextField")
                                                                                               flds.Add("DataValueField")
                                                                                       End Sub))
                                                 End Sub))
                       End Sub) _
                   .ID(ViewData.ModelMetadata.PropertyName) _
                   .Listeners(Sub(action)
                                      action.TriggerClick().AddScript("this.clearValue();")
                              End Sub) _
                   .Triggers(Sub(trg)
                                     trg.Add(Html.X.FieldTrigger().Icon(TriggerIcon.Clear).Qtip("Clear Selection"))
                             End Sub).Render()
        End If
    End Code
    I am receiving an error "Error executing child request for handler 'Ext.Net.SelfRenderingPage'." Is there another way that I shold go about creating an editor template with your controls?
    Last edited by Daniil; May 08, 2012 at 11:34 AM. Reason: [CLOSED]
  2. #2
    Hi,

    I'm not the best in VB Razor syntax, but I was able to get the following working.

    Example View
    @Html.X().ResourceManager()
    @code
        If Model IsNot Nothing Then
            Dim comboBox = Html.X().ComboBox().ValueField("DataValueField").DisplayField("DataTextField") _
                .QueryMode(DataLoadMode.Local) _
                .Store(Sub(action)
                               action.Add(Html.X.Store().DataSource(Model) _
                                          .Model(Sub(mdl)
                                                         mdl.Add(Html.X.Model().Fields(Sub(flds)
                                                                                               flds.Add("DataTextField")
                                                                                               flds.Add("DataValueField")
                                                                                       End Sub))
                                                 End Sub))
                       End Sub) _
                   .ID(ViewData.ModelMetadata.PropertyName) _
                   .Listeners(Sub(action)
                                      action.TriggerClick.Handler = "this.clearValue();"
                              End Sub) _
                   .Triggers(Sub(trg)
                                     trg.Add(Html.X.FieldTrigger().Icon(TriggerIcon.Clear).Qtip("Clear Selection"))
                             End Sub)
            @comboBox
        End If
    End Code
    Example Controller Action
    public ActionResult TestRazor()
    {
        return View(new List<object>() 
        {
            new 
            { 
                DataTextField = "text 1", 
                DataValueField = "value 1"
            },
            new 
            { 
                DataTextField = "text 2", 
                DataValueField = "value 2"
            },
        });
    }

Similar Threads

  1. Ext.net with asp.net or MVC3 ?
    By GKG4 in forum 2.x Help
    Replies: 1
    Last Post: Aug 14, 2012, 4:06 PM
  2. ObjectDataSource and MVC3
    By Therruco in forum 2.x Help
    Replies: 0
    Last Post: May 25, 2012, 3:23 PM
  3. Ext.net library with mvc3
    By Neha in forum 2.x Help
    Replies: 0
    Last Post: May 11, 2012, 9:02 AM
  4. Ext.Net with MVC3(Razor)
    By abanikumar in forum 1.x Help
    Replies: 4
    Last Post: Jan 16, 2012, 9:55 AM
  5. Replies: 2
    Last Post: Sep 23, 2009, 5:49 PM

Tags for this Thread

Posting Permissions