JQUERY CODE
function BindDropdown() {
$('#ddltest').select2({
ajax: {
type: "GET",
url: APIURL + "/api/Demo/GetNumbersList",
dataType: 'json',
data: function (params) {
var query = {
demoNum: params.term || "" ,
PageNum: params.page || 1,
PageSize: 20
}
// Query parameters will be ?search=[term]&page=[page]
return query;
},
processResults: function (data, params) {
params.page = params.page || 1;
return {
results: data.results,
pagination: {
more: (params.page * 20) < data.count_filtered
}
};
}
}
});
}
CONTROLLER CODE
public IHttpActionResult GetDemoNumbersList(string demoText, string PageNum, string PageSize)
{
List<IDTEXT> statusList = new List<IDTEXT>();
DataTable dataTable = demo.GetDemoNumList(demoText, Convert.ToInt32(PageNum), Convert.ToInt32(PageSize));
statusList = (from DataRow dr in dataTable.Rows
select new IDTEXT()
{
id = Convert.ToInt32(dr["DemoID"]),
text = Convert.ToString(dr["DemoText"])
}).ToList();
var returndata = new
{
results = statusList,
pagination = new { more = "true" },
count_filtered = dataTable.Rows[0]["TotalCount"].ToString()
};
return Ok(returndata);
}
No comments:
Post a Comment