Hi Tsvetomir,
As said before we are using Asp.Net Kendo UI (Not MVC).
We referred this link (https://docs.telerik.com/kendo-ui/api/javascript/data/datasource/configuration/transport.read#transport.read.cache) to bind the records in the grid. On this link, for ajax method you have used (https) link on URL to call the records on transport read property.
For the ajax method we have called the web on the code behind (static method).
We are getting the records on the datatable, change it to JsonConvert.SerializeObject & return it to Ajax.
Returned data is parsed & bound on the grid. Code snippet mentioned below for your reference.
JQuery - Ajax :
var gridDataSource = new kendo.data.DataSource({
transport: {
read: function (options) {
$.ajax({
type: "POST",
url: "History.aspx/BindGridDetails",
data: JSON.stringify({ "FromDate": $("#ContentPlaceHolder1_tdpFromDate").val(), "ToDate": $("#ContentPlaceHolder1_tdpToDate").val(), "CategoryId": $("#ContentPlaceHolder1_ddlCategory option:selected").text(), "AccountId": $("#ContentPlaceHolder1_ddlAccount option:selected").val() }),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
options.success(JSON.parse(response.d));
}
});
}
},
});
C# Code behind :
[WebMethod]
public static string BindGridDetails(DateTime FromDate, DateTime ToDate, string CategoryId,int AccountId)
{
DataTable DT = new DataTable();
int iOwnerID = Convert.ToInt32(HttpContext.Current.Session["OwnerID"]);
string sErrorMessage = string.Empty;
SqlDataReader DR = null;
DBClass DB = new DBClass();
if (DB.GetHistory(iOwnerID, AccountId, sCategoryID, ref DT, ref sErrorMessage, ref ToDate, ref FromDate) == false)
{
return sErrorMessage;
}
}
return JsonConvert.SerializeObject(DT);
}
Database class :
public bool GetHistory(int iOwnerID, int iLocationID, string sCategory, ref DataTable DT, ref string sErrorMessage, ref DateTime toDate, ref DateTime fromDate)
{
DT = new DataTable();
CreateNewCommand(CommandType.Text);
{
var withBlock = _cmd;
withBlock.CommandText = "SELECT top(190) Cast(T.EDate AS Date) as CompDate, T.ID AS TicketNumber, T.WorkOrder, L.Tag AS Account, " + "E.Unit, T.Cat, W.fDesc AS Mechanic, (T.Reg + T.OT + T.DT + T.NT) as Hours," + " CASE WHEN Charge = 1 or isnull(Invoice, 0) > 0 THEN '$' ELSE ' ' END AS Billable , T.fDesc AS ScopeOfWork, T.DescRes AS Resolution" + " FROM TicketD T " + " INNER JOIN Loc L ON T.Loc = L.loc " + " INNER JOIN tblWork W ON T.fWork = W.ID " + " LEFT JOIN Elev E ON T.Elev=E.ID " + " WHERE L.Owner = " + iOwnerID + GetHistoryWhere(iLocationID, sCategory) + " AND T.Internet = 1 AND EDate <= '" + toDate.Date + "' AND EDate >= '" + fromDate.Date + "'" + " ORDER BY T.EDate DESC";
try
{
SqlDataAdapter DA = new SqlDataAdapter(_cmd);
DA.Fill(DT);
}
catch (Exception X)
{
sErrorMessage = X.Message;
RemoveAllParameters(ref _cmd);
return false;
}
RemoveAllParameters(ref _cmd);
return true;
}
}
If we get Top(100/150) records, it is getting bound correctly on the grid but if we get more than 190 we get the error.
Video link mentioned below for your reference. Please check & let us know if you need more information on it.
Video Link