View:
@(Html.Kendo().Grid<ITNBuy.Models.BuyBuilder>()
.Name("gdBuy")
.AutoBind(false)
.HtmlAttributes("@class=gdBuy")
.Columns(columns =>
{
columns.Bound(p => p.cName).Title("Market").Width(150);
columns.Bound(p => p.cStation).Title("Station").Width(100);
columns.Bound(p => p.cDemo).Title("Demo").Width(100);
columns.Bound(p => p.cProduct).Title("Prod").Width(100);
columns.Bound(p => p.cDayofweek).Title("Days").Width(100);
columns.Bound(p => p.cTime).Title("Time").Width(100);
columns.Bound(p => p.cCode).Title("Code").Width(100);
columns.Bound(p => p.cProgram).Title("Program").Width(100);
columns.Bound(p => p.Cncl).Title("Cncl").Width(100);
})
.HtmlAttributes(new { style = "height:430px;" })
.DataSource(dataSource => dataSource
.Ajax()
.Batch(true)
.Read(read => read.Action("PopulateGrid", "BuyBuilder")
.Data("LoadParameters")
)
.Update(update => update.Action("Products_Update", "BuyBuilder"))
.Destroy(destroy => destroy.Action("Products_Destroy", "BuyBuilder"))
.ServerOperation(false) //false = don't read on page load
.PageSize(100)
//.Events(events => events.Error("error_handler"))
.Model(model =>
{
model.Id(p => p.buylineid);
model.Field(p => p.buylineid).Editable(false);
})
)
.Pageable()
.Editable(editable => editable.Mode(GridEditMode.InCell))
.Selectable()
.Sortable(sortable => sortable
.AllowUnsort(true )
.SortMode(GridSortMode.MultipleColumn))
.Scrollable(scrollable => scrollable.Virtual(true))
.ToolBar(toolBar =>
{
toolBar.Create();
toolBar.Save();
})
)
Controller:
public ActionResult PopulateGrid(string quarters, int? market, string station,
string client, string contract, int? show, string cost, string dp,
string start, string end,
string sortBy, bool blnFilter, bool includeTrade, bool exact, bool tradeonly, bool option,
[DataSourceRequest]DataSourceRequest request)
{
var userid = Session["UserId"].ToString();
int id = Int32.Parse(userid);
return Json(db.GetData(quarters, market, station, client, contract, show, cost, dp, start, end, sortBy, blnFilter, includeTrade, exact, tradeonly, option, id).ToDataSourceResult(request),
}
GetData Function:
public List<BuyBuilder> GetData(string quarters, int? market, string station,
string client, string contract, int? show, string cost, string dp, string start,
string end, string sortBy, bool blnFilter, bool blnIncludeTrade, bool blnExact, bool blnTradeonly,
bool blnOption, int userId)
{
List<BuyBuilder> list = new List<BuyBuilder>();
string conn = ConfigurationManager.ConnectionStrings["DevConnString"].ConnectionString;
SqlConnection cn = new SqlConnection(conn);
SqlCommand oCmd = new SqlCommand("Buy_BuyLine_Load", cn);
oCmd.CommandType = CommandType.StoredProcedure;
oCmd.Parameters.Add("@strQuarters", SqlDbType.VarChar).Value = quarters;
oCmd.Parameters.Add("@strStation", SqlDbType.VarChar).Value = station;
oCmd.Parameters.Add("@intShow", SqlDbType.Int).Value = show;
oCmd.Parameters.Add("@intUserId", SqlDbType.Int).Value = userId;
oCmd.Parameters.Add("@intMarket", SqlDbType.Int).Value = market;
SqlDataAdapter oAdptr = new SqlDataAdapter(oCmd);
DataSet dsResults = new DataSet();
cn.Open();
//oCmd.ExecuteNonQuery();
oCmd.CommandTimeout = 600;
// oAdptr.Fill(dsResults, "Results");
cn.Close();
var dataTable = new DataTable();
oAdptr.Fill(dataTable);
string costConvert = "";
foreach (DataRow dr in dataTable.Rows)
{
BuyBuilder u = new BuyBuilder();
u.buylineid = ((long)dr["buylineid"]);
u.cName = dr["cName"].ToString();
u.cStation = dr["cStation"].ToString();
u.cDemo = dr["cDemo"].ToString();
list.Add(u);
}
return list;
}
Not sure how many records before it fails but i know it works for 2500 records and fails for 5000 records. The grid just does not display the data once it returns more than 5000 records. Please help. I also tried virtualization and that did not work as well.
@(Html.Kendo().Grid<ITNBuy.Models.BuyBuilder>()
.Name("gdBuy")
.AutoBind(false)
.HtmlAttributes("@class=gdBuy")
.Columns(columns =>
{
columns.Bound(p => p.cName).Title("Market").Width(150);
columns.Bound(p => p.cStation).Title("Station").Width(100);
columns.Bound(p => p.cDemo).Title("Demo").Width(100);
columns.Bound(p => p.cProduct).Title("Prod").Width(100);
columns.Bound(p => p.cDayofweek).Title("Days").Width(100);
columns.Bound(p => p.cTime).Title("Time").Width(100);
columns.Bound(p => p.cCode).Title("Code").Width(100);
columns.Bound(p => p.cProgram).Title("Program").Width(100);
columns.Bound(p => p.Cncl).Title("Cncl").Width(100);
})
.HtmlAttributes(new { style = "height:430px;" })
.DataSource(dataSource => dataSource
.Ajax()
.Batch(true)
.Read(read => read.Action("PopulateGrid", "BuyBuilder")
.Data("LoadParameters")
)
.Update(update => update.Action("Products_Update", "BuyBuilder"))
.Destroy(destroy => destroy.Action("Products_Destroy", "BuyBuilder"))
.ServerOperation(false) //false = don't read on page load
.PageSize(100)
//.Events(events => events.Error("error_handler"))
.Model(model =>
{
model.Id(p => p.buylineid);
model.Field(p => p.buylineid).Editable(false);
})
)
.Pageable()
.Editable(editable => editable.Mode(GridEditMode.InCell))
.Selectable()
.Sortable(sortable => sortable
.AllowUnsort(true )
.SortMode(GridSortMode.MultipleColumn))
.Scrollable(scrollable => scrollable.Virtual(true))
.ToolBar(toolBar =>
{
toolBar.Create();
toolBar.Save();
})
)
Controller:
public ActionResult PopulateGrid(string quarters, int? market, string station,
string client, string contract, int? show, string cost, string dp,
string start, string end,
string sortBy, bool blnFilter, bool includeTrade, bool exact, bool tradeonly, bool option,
[DataSourceRequest]DataSourceRequest request)
{
var userid = Session["UserId"].ToString();
int id = Int32.Parse(userid);
return Json(db.GetData(quarters, market, station, client, contract, show, cost, dp, start, end, sortBy, blnFilter, includeTrade, exact, tradeonly, option, id).ToDataSourceResult(request),
}
GetData Function:
public List<BuyBuilder> GetData(string quarters, int? market, string station,
string client, string contract, int? show, string cost, string dp, string start,
string end, string sortBy, bool blnFilter, bool blnIncludeTrade, bool blnExact, bool blnTradeonly,
bool blnOption, int userId)
{
List<BuyBuilder> list = new List<BuyBuilder>();
string conn = ConfigurationManager.ConnectionStrings["DevConnString"].ConnectionString;
SqlConnection cn = new SqlConnection(conn);
SqlCommand oCmd = new SqlCommand("Buy_BuyLine_Load", cn);
oCmd.CommandType = CommandType.StoredProcedure;
oCmd.Parameters.Add("@strQuarters", SqlDbType.VarChar).Value = quarters;
oCmd.Parameters.Add("@strStation", SqlDbType.VarChar).Value = station;
oCmd.Parameters.Add("@intShow", SqlDbType.Int).Value = show;
oCmd.Parameters.Add("@intUserId", SqlDbType.Int).Value = userId;
oCmd.Parameters.Add("@intMarket", SqlDbType.Int).Value = market;
SqlDataAdapter oAdptr = new SqlDataAdapter(oCmd);
DataSet dsResults = new DataSet();
cn.Open();
//oCmd.ExecuteNonQuery();
oCmd.CommandTimeout = 600;
// oAdptr.Fill(dsResults, "Results");
cn.Close();
var dataTable = new DataTable();
oAdptr.Fill(dataTable);
string costConvert = "";
foreach (DataRow dr in dataTable.Rows)
{
BuyBuilder u = new BuyBuilder();
u.buylineid = ((long)dr["buylineid"]);
u.cName = dr["cName"].ToString();
u.cStation = dr["cStation"].ToString();
u.cDemo = dr["cDemo"].ToString();
list.Add(u);
}
return list;
}
Not sure how many records before it fails but i know it works for 2500 records and fails for 5000 records. The grid just does not display the data once it returns more than 5000 records. Please help. I also tried virtualization and that did not work as well.