[CLOSED] [Razor] Select Combobox item from model value

Threaded View

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

    [CLOSED] [Razor] Select Combobox item from model value

    Hi there,

    I've got several combo boxes such as this one:
    fields.Add(Html.X().ComboBox()
              .FieldLabel("Service Status")
              .LabelAlign(LabelAlign.Top)
              .ID("ddlServiceStatus")
              .Margins("0 0 0 0")
              .LabelWidth(200)
              .Width(200)
              .EmptyText("--- Please Select ---")
              .Cls("form-label")
              .DisplayField("ServiceStatusName")
              .ValueField("ServiceStatusId")
              .Store(store => store.Add(Html.X().Store()
                     .AutoLoad(true)
                     .Proxy(proxy => proxy.Add(Html.X().AjaxProxy()
                             .Url("/Services/RetrieveServiceStatuses/")
                             .Reader(reader => reader.Add(Html.X().JsonReader()
                             .Root("data")
                             .TotalProperty("total")
                         ))
                 ))
                 .Model(model => model.Add(Html.X().Model()
                            .Fields(modelFields =>
                            {
                                     modelFields.Add(Html.X().ModelField().Name("ServiceStatusID"));
                                     modelFields.Add(Html.X().ModelField().Name("ServiceStatusName"));
                           })
                  ))
                  )
           )
    );
    The page this field resides on gets on MVC model from the controller on load and I need to use the Model.ServiceStatus value to pre-select the relevant combobox item. I've tried a few methods - using the selecteditems attribute and a load handler but I'm obviously not doing it correctly... What is the correct way to do this in razor syntax?
    Last edited by Daniil; May 18, 2012 at 4:53 PM. Reason: [CLOSED]

Similar Threads

  1. [CLOSED] How to select a ComboBox item by value?
    By vadym.f in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Apr 16, 2012, 4:15 PM
  2. I can not select any item in combobox
    By marco.amusquivar in forum 1.x Help
    Replies: 1
    Last Post: Mar 21, 2012, 8:09 PM
  3. [CLOSED] Combobox, select first item
    By Yevgeniy in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Nov 28, 2011, 12:05 PM
  4. Replies: 0
    Last Post: Sep 20, 2010, 8:56 PM
  5. Select a item in a Combobox
    By eliezer in forum 1.x Help
    Replies: 1
    Last Post: Apr 16, 2009, 12:23 PM

Posting Permissions