2012-10-10 149 views
1

我想按照姓氏過濾表,但不能工作,這是我的代碼劍道UI無法濾除電網表

在控制器

public JsonResult Filtering() 
    { 
     HealthContext rc = new HealthContext(); 
     var last = rc.Profiles.Select(lastt => new SelectListItem { Text = lastt.LastName, Value = lastt.Id.ToString() }).ToList(); 
     return Json(last.ToList(), JsonRequestBehavior.AllowGet); 


    } 

鑑於

<script type="text/x-kendo-template" id="template"> 
      <div class="toolbar"> 
       <label class="category-label" for="Last name"> by last name:</label> 
       <input type="search" id="LastName" style="width: 230px"></input> 
      </div> 
     </script> 

並且還

以下片段是用於顯示錶和濾波該姓

<script> 
        $(document).ready(function() { 
         $("#grid").kendoGrid({ 
          dataSource: { 

           transport: { 
            read: { 
             url: "/Profiles/GetJsonData", 
             dataType: "json" 
            } 
           }, 

           pageSize: 10, 

          }, 
         toolbar: kendo.template($("#template").html()), 
          height: 250, 
          filterable: true, 
          sortable: true, 
          pageable: true, 
          defaultSorting: 'LastName ASC', 
          columns: [{ 
            field: "Id", 
            filterable: false 
           }, 

           { 
            field: "FirstName", 
            title: "First Name", 

            width: 100, 

           }, { 
            field: "LastName", 
            title: "Last Name", 

            width: 200 
           }, { 
            field: "Gender", 
            title: "Gender" 
           } 
          ] 
         }); 


         var dropDown = grid.find("#LastName").kendoDropDownList({ 
              dataTextField: "LastName", 
              dataValueField: "Id", 
              autoBind: false, 
              optionLabel: "All", 
              dataSource: { 

          severFiltering: true, 
          transport: { 
            read: { 
             url: "/Profiles/Filtering", 
             dataType: "json" 
            } 
           }, 
         }, 
         change: function() { 
          var value = this.value(); 
          if (value) { 
           grid.data("kendoGrid").dataSource.filter({ field: "Id", operator: "eq", value: parseInt(value) }); 
          } else { 
           grid.data("kendoGrid").dataSource.filter({}); 
          } 
         } 

       }); 
       }); 
       </script> 

所以問題是下拉列表不顯示以及價值/數據,任何想法傢伙?

回答

1

在你的代碼不同意什麼電網變量後面?你也可以通過id直接找到姓氏html元素。

var dropDown = $("#LastName").kendoDropDownList({ ... 

休息你的代碼看起來好,那就是:

http://jsfiddle.net/knWcJ/70/