2014-05-15 3 views
1

읽기 용으로 ajax 바인딩을 사용하는 ASP.NET MVC 앱에 Kendo Grid를 사용합니다. 첫 번째 페이지에 데이터를 바인딩하지만 표의 번호 페이지는 표시하지 않습니다. (| < < 0>> |).Kendo Grid가 페이징 데이터가 아닙니다.


Index.cshtml

 @(Html.Kendo().Grid<Club.Areas.Admin.Models.Users>() 
      .Name("grid")     
      .DataSource(dataSource => dataSource 
       .Ajax() 
       .Read(read => read.Action("List1", "Home")) 
       .PageSize(5)             
      )     
      .Columns(columns => 
      { 
       columns.Bound(p => p.Id).Filterable(false).Width(100); 
       columns.Bound(p => p.NickName).Width(100); 
       columns.Bound(p => p.UserVisitLastDate).Format("{0:MM/dd/yyyy}").Width(140);      
       columns.Bound(p => p.Mobile).Width(100); 
      }) 
      .Pageable()     
      .Sortable()     
      .HtmlAttributes(new { style = "width:500px;height:430px;" })     
    ) 


HomeController

public class HomeController : Controller 
{   
    public ActionResult Index() 
    { 
     return View(); 
    } 

    public ActionResult List1([DataSourceRequest]DataSourceRequest request) 
    { 
     List<Users> U = new List<Users>(); 
     for (int i = 0; i < 100; i++) 
     { 
      U.Add(new Users 
      { 
       NickName = "Mehdi", 
       Company = "Taral", 
       Email = "[email protected]", 
       Family = "FT", 
       HomeAddress = "Isfahan", 
       HomePhone = "03112332940", 
       IsActive = true, 
       Mobile = "09131025834", 
       Name = "Mehdi", 
       UserCreateDate = DateTime.Now, 
       UserVisitLastDate = DateTime.Now, 
       WebSite = "", 
       WorkAddress = "Mehdi", 
       PostalCode = "1234567890", 
       Id = i, 
       WorkPhone = "03117726250" 
      }); 
     } 
     DataSourceResult result = U.ToDataSourceResult(request);    
     return Json(result,JsonRequestBehavior.AllowGet);    
    } 
} 
+0

스크린 샷을 게시 할 수 있습니까? –

답변

0

당신은 데이터 소스의 serverPaging: true을 설정하고 서버에서 응답이 전체 필드가 ​​있는지 확인해야합니다 항목의 금액.

0

내 대답은 MVC 방식과 완전히 관련이 없으며 WebAPI 컨트롤러와 함께 사용했습니다. 데이터 소스는 다음과 같이 보일 것이다 : 그것은 총 레코드 수를 얻고 표시하는 페이지 수를 계산하는 경우

var sampleDataSource = new kendo.data.DataSource({ 
    transport: { 
     read: { 
      url: svcSampleUrl, 
      contentType: "application/json; charset=utf-8", 
      type: "POST", 
      dataType: "json" 
     }, 
     parameterMap: function (options) { 
      model.Take = options.take; 
      model.Skip = options.skip; 
      model.Sort = options.sort; 
      model.Filter = options.filter; 
      return kendo.stringify(model); 
     } 
    }, 
    schema: { 
     data: "sampleDTOList", 
     total: "totalItems", 
     model: { 
      fields: { 
       ID: { type: "number" }, 
       Label: { type: "string" }, 
       Description: { type: "string" } 
      } 
     } 
    }, 
    serverPaging: true, 
    serverFiltering: true, 
    serverSorting: true 
}); 

스키마의 총 속성입니다. 귀하의 경우 첫 번째 페이지의 데이터를 받고 있으며 그리드는 필요한 총 페이지 수를 계산하기 위해 얼마나 많은 데이터가 있는지 알지 못합니다.

관련 문제