我正在使用Telerik MVC 4.我想製作一個組合框和下拉列表。但它總是顯示文本框。如何使用Kendo UI進行下拉
這是控制器
[Authorize]
public JsonResult GetProvinsiByJSON()
{
var propinsi = db.Tbl_Propinsi.Where(b => b.flag == "Y").Select(b => new { Value = b.id_propinsi, Text = b.propinsi }).AsEnumerable();
return Json(propinsi, JsonRequestBehavior.AllowGet);
}
這是我的看法
@{
ViewBag.Title = "Kota";
Layout = "~/Views/Shared/_adminLayout.cshtml";
}
<div class="tables">
<div class="table-responsive bs-example widget-shadow">
<h4>Data Kota:</h4>
<div>
<form>
<div class="form-group">
<label for="kategori">Tambah Kota</label>
<br/>
@(Html.Kendo().ComboBox()
.Name("provId")
.Placeholder("Pilih Provinsi")
.DataTextField("Text")
.DataValueField("Value")
.HtmlAttributes(new { style = "width:100%;" })
.Filter("contains")
.DataSource(source => { source.Read(read => read.Action("GetProvinsiByJSON", "Lokasi")); })
)
@(Html.Kendo().DropDownList()
.Name("provID")
.OptionLabel("Please select Provinsi ...")
.HtmlAttributes(new { style = "width:40%" })
.DataTextField("Text")
.DataValueField("Value")
.Filter("contains")
.DataSource(source => { source.Read(read => read.Action("GetProvinsiByJSON", "Lokasi")); })
)
<input type="text" class="form-control" id="kota" name="kota" placeholder="Nama Kota">
<button type="submit" class="btn btn-default">Simpan</button>
</div>
</form>
</div>
<table class="table table-bordered">
<thead>
<tr>
<th>No</th>
<th>Kota</th>
<th>Provinsi</th>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
這是我所得到的,只是一個空的文本框
請幫助我。先進的感謝
請注意,模型 - 視圖 - 控制器標籤是關於模式的問題。 ASP.NET-MVC實現有一個特定的標籤。 –
根據我的經驗,這種行爲通常來自Kendo UI視圖中存在的Javascript錯誤。請使用瀏覽器的開發人員工具檢查您的瀏覽頁面,並在此處顯示錯誤信息 –