2014-02-12 144 views
0

我有三個級聯的劍道dropdownlist,第一個和第二個是正確的,但第三個沒有顯示在頁面加載optionlabel。劍道下拉列表級聯第三級不顯示optionlabel

imageOfDropDownList

,你可以看到,在「城」 dropdowlist不顯示optionLabel即使它有它,如在控制檯中。

我不知道爲什麼會發生,因爲它是一樣的劍道演示的例子:

Link to demo

這裏是剃刀代碼:

 <div class="baseControlsLine rowLineHeight lineMap"> 
      <div class="labelControlWith"> @Html.Label(@BackOffice.lblCountry + ":", htmlAttributes: new { @class = "baseLabel mapLabel" })</div> 
      <div class="baseControlSmall"> 
       @(Html.Kendo().DropDownListFor(c => c.Customer.MapCountry) 
        .OptionLabel(BackOffice.txtSelectCountry) 
        .Events(e => e.Close("CustomerCreateEdit.CreateAddresMap").DataBound("CustomerCreateEdit.DataBound")) 
        .DataTextField("Text") 
        .DataValueField("Value").HtmlAttributes(new { @class = "baseTextbox" }) 
        .DataSource(source => { 
         source.Read(read => { 
          read.Action(Constants.GET_COUNTRIES_SELECT_LIST, Constants.CUSTOMER_CONTROLLER); 
         }); 
        })) 
       @Html.ValidationMessageFor(model => model.Customer.MapCountry) 
      </div> 
     </div> 
     <div class="baseControlsLine rowLineHeight lineMap"> 
      <div class="labelControlWith"> @Html.Label(@BackOffice.lblProvince + ":", htmlAttributes: new { @class = "baseLabel mapLabel" })</div> 
      <div class="baseControlSmall"> 
       @(Html.Kendo().DropDownListFor(c => c.Customer.MapProvince) 
        .Events(e => e.Close("CustomerCreateEdit.CreateAddresMap")) 
        .OptionLabel(BackOffice.txtSelectProvince) 
        .DataTextField("Text") 
        .DataValueField("Value").HtmlAttributes(new { @class = "baseTextbox" }) 
        .CascadeFrom("Customer_MapCountry") 
        .DataSource(source => { 
         source.Read(read => { 
          read.Action(Constants.GET_PROVINCES_SELECT_LIST, Constants.CUSTOMER_CONTROLLER).Data("CustomerCreateEdit.GetCountryId"); 
         }).ServerFiltering(true); 
        })) 
       @Html.ValidationMessageFor(model => model.Customer.MapProvince) 
      </div> 
     </div> 
     <div class="baseControlsLine rowLineHeight lineMap"> 
      <div class="labelControlWith"> @Html.Label(@BackOffice.lblCity + ":", htmlAttributes: new { @class = "baseLabel mapLabel" })</div> 
      <div class="baseControlSmall"> 
       @(Html.Kendo().DropDownListFor(c => c.Customer.MapCity) 
        .Events(e => e.Close("CustomerCreateEdit.CreateAddresMap")) 
        .OptionLabel(BackOffice.txtSelectCity) 
        .DataTextField("Text") 
        .DataValueField("Value").HtmlAttributes(new { @class = "baseTextbox" }) 
        .CascadeFrom("Customer_MapProvince") 
        .DataSource(source => { 
         source.Read(read => { 
          read.Action(Constants.GET_CITIES_SELECT_LIST, Constants.CUSTOMER_CONTROLLER).Data("CustomerCreateEdit.GetProvinceId"); 
         }).ServerFiltering(true); 
        })) 
       @Html.ValidationMessageFor(model => model.Customer.MapCity) 
      </div> 
     </div> 

這裏javascript的代碼:

GetCountryId: function() { 
    /// <signature> 
    /// <summary>Devuelve el id del country para la cascada.</summary> 
    /// </signature> 
    return { 
     id: $("#Customer_MapCountry").val() 
    }; 
}, 
GetProvinceId: function() { 
    /// <signature> 
    /// <summary>Devuelve el id de la provincia para la cascada.</summary> 
    /// </signature> 
    return { 
     id: $("#Customer_MapProvince").val() 
    }; 
}, 

這裏的控制器:

public JsonResult GetCitiesSelectList(int? id) { 
     if (!id.HasValue) 
      return Json(new SelectListItem() { Text = BackOffice.txtSelectCity }, JsonRequestBehavior.AllowGet); 
     List<CityLanguage> listCity = _applicationCity.GetAllWithLanguage(id.Value).ToList(); 
     return Json(new SelectList(listCity, "IdCity", "Name"), JsonRequestBehavior.AllowGet); 
    } 
    public JsonResult GetProvincesSelectList(int? id) { 
     if (!id.HasValue) 
      return Json(new SelectListItem() { Text = BackOffice.txtSelectProvince }, JsonRequestBehavior.AllowGet); 
     List<ProvinceLanguage> listProvince = _applicationProvince.GetAllWithLanguage(id.Value).ToList(); 
     return Json(new SelectList(listProvince, "IdProvince", "Name"), JsonRequestBehavior.AllowGet); 
    } 
    public JsonResult GetCountriesSelectList() { 
     List<CountryLanguage> listCountryLanguage = _applicationCountry.GetAllWithLanguage().ToList(); 
     return Json(new SelectList(listCountryLanguage, "IdCountry", "Name"), JsonRequestBehavior.AllowGet); 
    } 

編輯:

我有問題與jQuery的版本,我不得不把JavaScript的順序是:

jQuery的。 劍道。 jquery-ui。

它可能是錯誤是爲了JavaScript的順序?

另外我有一個版本的jquery,它不是一個與劍道。

這有可能會導致第三個dropdownlist的奇怪行爲?

+0

顯示下拉列表中的代碼,所以我們可以幫助你。 – Jaimin

+0

我編輯了這個問題,謝謝。 –

回答

0

嗨,你好,Placeholder insp OptionLabel

@(Html.Kendo().DropDownListFor(c => c.Customer.MapCountry) 
        .Placeholder(BackOffice.txtSelectCountry) 
        .Events(e => e.Close("CustomerCreateEdit.CreateAddresMap").DataBound("CustomerCreateEdit.DataBound")) 
        .DataTextField("Text") 
        .DataValueField("Value").HtmlAttributes(new { @class = "baseTextbox" }) 
        .DataSource(source => { 
         source.Read(read => { 
          read.Action(Constants.GET_COUNTRIES_SELECT_LIST, Constants.CUSTOMER_CONTROLLER); 
         }); 
        })) 
+0

嗨Jaimin,抱歉,我的劍道版中沒有佔位符選項,我認爲我有最後一個。 –

+0

@AlbertCortada好,那我必須檢查。 – Jaimin