我試圖從SmartTable中完成當前tableState的asp.net映射。AngularJS SmartTable&ASP.NET映射錯誤
我使用ASP.NET MVC 5.
我angularjs調用這個樣子的:
usersService.getUsers({
start: start,
number: number,
tableState: tableState
}
).then(function(result) {
});
我的queryString參數是這樣的:
number:10
start:0
tableState:{"sort":{"predicate":"location","reverse":false},"search":{"predicateObject":{"location":"gfdgd","service":"gfdgd","company":"gd","fullname":"john"}},"pagination":{"start":0,"number":10}}
,當然我試着在asp.net中查詢查詢信息。我的控制器操作是這樣的:
public JsonResult GetUsers(SmartTableRequestModel request)
{
return GetJsonResult(new
{
});
}
而我試圖在綁定的模式有以下幾種:
public class SmartTableRequestModel
{
public SmartTableQueryModel TableState { get; set; }
public int Number { get; set; } // number is well-binded
public int Start { get; set; } // the start is well-binded too
}
public class SmartTableQueryModel
{
[JsonProperty("sort")]
public SmartTableSortModel Sort { get; set; }
[JsonProperty("search")]
public SmartTableSearchModel Search { get; set; }
[JsonProperty("pagination")]
public SmartTablePaginationModel Pagination { get; set; }
}
public class SmartTableSortModel
{
[JsonProperty("predicate")]
public string Predicate { get; set; }
[JsonProperty("reverse")]
public bool Reverse { get; set; }
}
等等......
,但我沒有得到在tableState模型中映射的任何東西。我的SmartTableRequestModel對象中的TableState屬性始終爲空。
感謝您的幫助下, 勒茲萬
我假設你使用的是asp.net MVC。你可以請張貼更多的細節,比如你正在使用什麼版本的MVC? –
我更新了我的問題。對不起。我使用ASP.NET MVC 5. –
您是否嘗試過使用TypeConverters或模型聯編程序?請參閱http://www.asp.net/web-api/overview/formats-and-model-binding/parameter-binding-in-aspnet-web-api – mentat