2017-04-05 1 views
0

フィルタされたデータをグリッドに表示したいのですが、それはなぜmonthYearfilter where節の後に表示されないのかわかりません。剣道のグリッドにデータをバインドします。 currentmonthyearを使用しますが、monthYearfilterでは使用しません。以前は同じプロジェクトを別のプロジェクトで使用していましたが、うまく動作しています。剣道のDataSourceResultをlinqを使ってwhere節の後に表示

linq where節の後にDataSourceResult結果のデータを取得しますが、グリッドには表示されません。

//コントローラのコード

[HttpPost] 
    public ActionResult BillingChecklist_Read([DataSourceRequest]DataSourceRequest request,string monthYearfilter) 
     { 


     using (var preemploymentdata = new AREntities()) 
     { 
      IQueryable<BillingCheckList> preEmploymentWorkflows = preemploymentdata.BillingCheckLists; 


      DataSourceResult result; 




      if (monthYearfilter != null) 
      { 

       result = preEmploymentWorkflows.Where(x => x.MonthYear == monthYearfilter).ToDataSourceResult(request); 
      } 
      else 
      { 

       string currentmonthyear = DateTime.Now.Year + "/0" + DateTime.Now.Month; 

       result = preEmploymentWorkflows.Where(x => x.MonthYear == currentmonthyear).ToDataSourceResult(request); 
      } 



      return Json(result); 


     } 
    } 

//コードの表示

@{ 

    Html.Kendo().Grid<BillingCheckList>() 
      .Name("MyGrid") 
      .DataSource(dataSource => dataSource 
       .Ajax() 

    .Read(read => read.Action("BillingChecklist_Read", "BillingChecklist")) 
       .Model(model => model.Id(p => p.OfficePrefix)) 
      ) 



    .Columns(col => 
      { 


       col.Bound(o =>.OfficePrefix).Groupable(false).Title("Offices"); 

       col.Bound(o => o.MonthYear).Title("MonthYear").Visible(false); 

       col.Group(group => group 
        .Title("Time Entered & Completed").HeaderHtmlAttributes(new { style = "text-align:center" }) 
        .Columns(info => 
        { 
         info.Bound(o => o.IsTimeWk1).HeaderHtmlAttributes(new { style = "text-align:center" }).HtmlAttributes(new { style = "text-align:left" }) 
          .ClientTemplate("<input type='checkbox' #= IsTimeWk1 ? checked='checked': '' # onclick='UpdateCheckBox(#= BilingChecklistID #, \"#= OfficePrefix #\", \"#= 'IsTimeWk1'#\", \"#= IsTimeWk1 #\" )'/>") 
          .Title("WK<br>1").Width(5); 

         info.Bound(o => o.IsTimeWk2).HeaderHtmlAttributes(new { style = "text-align:center" }).HtmlAttributes(new { style = "text-align:left" }) 
          .ClientTemplate("<input type='checkbox' #= IsTimeWk2 ? checked='checked': '' # onclick='UpdateCheckBox(#= BilingChecklistID #, \"#= OfficePrefix #\", \"#= 'IsTimeWk2'#\", \"#= IsTimeWk2 #\" )' />") 
          .Title("WK<br>2").Width(5); 

         info.Bound(o => o.IsTimeWk3).HeaderHtmlAttributes(new { style = "text-align:center" }).HtmlAttributes(new { style = "text-align:left" }) 
          .ClientTemplate("<input type='checkbox' #= IsTimeWk3 ? checked='checked': '' # onclick='UpdateCheckBox(#= BilingChecklistID #, \"#= OfficePrefix #\", \"#= 'IsTimeWk3'#\", \"#= IsTimeWk3 #\" )'/>") 
          .Title("WK<br>3").Width(5); 

         info.Bound(o => o.IsTimeWk4).HeaderHtmlAttributes(new { style = "text-align:center" }).HtmlAttributes(new { style = "text-align:left" }) 
          .ClientTemplate("<input type='checkbox' #= IsTimeWk4 ? checked='checked': '' # onclick='UpdateCheckBox(#= BilingChecklistID #, \"#= OfficePrefix #\", \"#= 'IsTimeWk4'#\", \"#= IsTimeWk4 #\" )'/>") 
          .Title("WK<br>4").Width(5); 

         info.Bound(o => o.IsTimeWk5).HeaderHtmlAttributes(new { style = "text-align:center" }).HtmlAttributes(new { style = "text-align:left" }) 
          .ClientTemplate("<input type='checkbox' #= IsTimeWk5 ? checked='checked': '' # onclick='UpdateCheckBox(#= BilingChecklistID #, \"#= OfficePrefix #\", \"#= 'IsTimeWk5'#\", \"#= IsTimeWk5 #\" )'/>") 
          .Title("WK<br>5").Width(5); 
        })); 

})   .Sortable() 
      .Render(); 


} 

答えて

0

あなたはサーバ側のデータのフィルタリングされているので、あることからデータを防止するために、DataSourceResultを返す前に、フィルタをクリアしてみてくださいクライアント側で再びフィルタリングされます。

result.Filters.Clear(); 

return Json(result); 
関連する問題