2012-12-18 2 views
0

정렬 가능으로 설정된 검도 표가 있습니다. jQuery를 사용하여 Ajax 포스트 백을 수행하여 정렬 정보를 액션 메소드로 보내 액션을 수행하고 싶습니다.검도 UI - Ajax MVC - JSON 항상 null

var datasource = $(".data-table").data("kendoGrid").dataSource; 
$.ajax({ 
    type: 'POST', 
    url: '@Url.Action("ExportToPDf", "MyController")', 
    dataType: 'json', 
    data: { sort: datasource._sort } 
}); 

나는 올바른 값을 가지고와 아약스의 데이터 속성에 전달되는 debugger로 볼 수 있어요. FireBug를 사용하여 값이 POST 작업 중에 전달되는지 확인했습니다. POST 액션

sort[0][dir] asc 
sort[0][field] EmployeeRef 

동안 방화범에서

public ActionResult ExportToPDf(List<SortDescription> sort) 
{ 
    //Will be doing some action 
    return null; 
} 

public class SortDescription 
{ 
    public string dir { get; set; } 
    public string field { get; set; } 
} 

샘플 데이터는 I 목록에 하나 개의 항목을 얻을 메신저 수, 액션 메소드에 중단 점을 유지하면되지만 속성은 null이 될 것으로 보인다.

누구든지 나를 잘못 안내 할 수 있습니까? 이 같은

답변

2

시도 뭔가 :

$.ajax({ 
    url: '@Url.Action("ExportToPDf", "MyController")', 
    type: 'POST', 
    dataType: 'json', 
    contentType: 'application/json; charset=utf-8', 
    data: JSON.stringify({sort: datasource._sort }) 
})