admin管理员组文章数量:1355564
I have my controller method as follows
[HttpGet]
public JsonResult GetClientAccount([DataSourceRequest] DataSourceRequest request, string partyId)
{
try
{
using (var client = GetWebClient(WebClientContentType.JSON))
{
string clientApiResponse = client.DownloadString(new Uri(_webApiUrl + "/api/Client/GetClientAccountinfo/" + partyId));
var rawResponse = JsonConvert.DeserializeObject<string>(clientApiResponse);
ClientAccountJsonViewModel clientInfo = JsonConvert.DeserializeObject<ClientAccountJsonViewModel>(rawResponse);
if (clientInfo?.Data == null || !clientInfo.Data.Any())
{
return Json(new DataSourceResult { Data = new List<ClientAccountInvoice>(), Total = 0 }, JsonRequestBehavior.AllowGet);
}
var clientAccs = clientInfo.Data
.Select(data => new ClientAccountInvoice
{
Description = data.InvoiceDescription,
InvoiceNumber = data.InvoiceNumber ?? ""
})
.AsQueryable(); // Convert to IQueryable for server-side operations
// Apply server-side operations (filtering, sorting, paging)
var result = clientAccs.ToDataSourceResult(request);
// The Total is automatically set by ToDataSourceResult based on filtered count
return Json(result, JsonRequestBehavior.AllowGet);
}
}
catch (Exception ex)
{
// Log error
return Json(new DataSourceResult { Data = new List<ClientAccountInvoice>(), Total = 0 }, JsonRequestBehavior.AllowGet);
}
}
My .cshtml
is as follows:
<div id="grid"></div>
$("#grid").kendoGrid({
dataSource: {
transport: {
read: {
url: "/Client/GetClientAccount",
type: "GET",
dataType: "json",
data: function () {
return { partyId: $(".clientnumber-text").text().trim() };
}
}
},
serverPaging: true,
serverSorting: true,
serverFiltering: true,
columns: [{ field: "InvoiceNumber", title: "Invoice No" }],
pageSize: 20, // Adjust as needed
schema: {
data: "Data",
total: "Total"
}
},
columns: [
{ field: "Description", filterable: false, title: "Description", width: "200px" },
{
field: "InvoiceNumber", title: "InvoiceNumber", width: "120px",
template: "#if(TransactionType && InvoiceNumber && InvoiceNumber.trim() != '' && InvoiceNumber != '0') {#" +
"<a style='cursor: pointer;' " +
"id='#=InvoiceNumber#' " +
"onclick='downloadDoc(\"#=InvoiceNumber#\", #=getHeaderMenuId()#, \"#=SourceSystem#\")' " +
"name='#=InvoiceNumber#'>#=InvoiceNumber#</a>" +
"#} else {# #=InvoiceNumber# #} #"
},
],
pageable: true,
sortable: true,
filterable: true
});
But when I apply filter on InvoiceNumber
, I am unable to see that on server side
I tried changing to post method but still the same do can some one let me know where I am doing wrong.
本文标签: cUnable to pass filters for kendo grid along with a parameter in ASPNET MVCStack Overflow
版权声明:本文标题:c# - Unable to pass filters for kendo grid along with a parameter in ASP.NET MVC - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743957746a2568440.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论