Also, when building a grid that reads any data set, the endpoint should always have paging related parameters like PageNumber, PageSize, and few others. The only part of the data set that's relevant to the current display should be retrieved. Data joining should not be done at the web UI level.
$.ajax({ type: "POST", url: "http://localhost:5000/Search/GetData", data: JSONData, }).done(function (msg) { alert("Data Saved: " + msg); });
For the JSONData, you could build out a string that matches with the class signature, DataContract
public class SearchResult { public JsonResult data { get; set; } public int PageNumber { get; set; } public int PageSize { get; set; } public int PageCount { get; set; } public int DataCount { get; set; } }
public class SearchPackage { public SearchItem[] Items { get; set; } public int PageNumber { get; set; } public int PageSize { get; set; } }
public class SearchItem { public string FieldName { get; set; } public string Value { get; set; } public SortDirection SortDirection { get; set; } }
var JSONData = { "SearchItem": [{ "fieldName": "LastName", "value": "Smith", "sortDirection": "SortDirection.ASC" }, { "fieldName": "FirstName", "value": "John", "sortDirection": "SortDirection.DESC"}]};If you are passing an url value for the data, you can dourl: "http://localhost:5000/Search/GetData?fieldNames=LastName&fieldNames=FirstName&values=Smith&values=John&sortDirections=SortDirection.ASC&sortDirections=SortDirection.Desc";
[HttpPost] public JsonDataResult GetData(List<string> fieldNames, List<string> values, List<int> sortDirections) {using (var proxy = searchFactory.CreateChannel()) {SearchResult oSearchResult = SearchFactory.GetRequestPackage(Transform(fieldNames, values, sortDirections)); return Json(oSearchResult );} }Since there are two parameters called the fieldNames, such parameters is like passing a ListfieldName.
No comments:
Post a Comment