2016-07-15 4 views
-1

Telerik MVCを使用しています。4.コンボボックスとドロップダウンリストを作成します。しかし、それは常にテキストボックスを表示します。剣道UIを使用してドロップダウンを行う方法

これはこれはこれは、私が何を得るだけで、空のテキストボックス

enter image description here

ある

@{ 
    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> 

私のビューでコントローラ

[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); 
     } 

である私を助けてください。ありがとうございました

+0

model-view-controllerタグは、パターンに関する質問用です。 ASP.NET-MVCの実装には特定のタグがあります。 –

+0

私の経験から、この動作は、通常、剣道のUIビューにJavascriptのエラーがあることに起因します。ブラウザのデベロッパーツールを使用してビューページを確認し、ここにエラーを掲載してください。 –

答えて

2

JavaScriptエラーや剣道UIに必要なリソースが不足している可能性が最も高いです。期待通りに動作するように剣道UIスクリプトためには

、あなたが スクリプトの前に文書でjQueryライブラリへの参照を含める ことを確認してください。

次のリンクを見てください:

http://docs.telerik.com/kendo-ui/intro/installation/prerequisites#javascript-prerequisites http://docs.telerik.com/kendo-ui/intro/installation/getting-started#host-kendo-ui-in-your-project

は、この情報がお役に立てば幸いです。

+0

ありがとうございますが、dbのデータはまだ入力できません。なぜなのかご存知ですか? –

関連する問題