This is a migrated thread and some comments may be shown as answers.

Grid does not display data when return record is over 5000

2 Answers 630 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Xinzhou
Top achievements
Rank 1
Xinzhou asked on 16 Jun 2014, 04:24 PM
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.


2 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 17 Jun 2014, 10:37 AM
Hello Xinzhou,

When you set ServerOperation to false, all data rows will be sent to the client with the first request. If they are too many, you will hit the JSON Serializer limit, which is not related to Kendo UI.

http://docs.telerik.com/kendo-ui/getting-started/using-kendo-with/aspnet-mvc/helpers/grid/troubleshooting#error-during-serialization-or-deserialization-using-the-json-javascriptserializer

By the way, please do not confuse ServerOperation(false) with AutoBind(false). The comment below is not correct, as it applies to AutoBind(false).

.ServerOperation(false) //false = don't read on page load


Regards,
Dimo
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Xinzhou
Top achievements
Rank 1
answered on 17 Jun 2014, 01:30 PM
That's exactly it!!! Thanks for your help.

I must have put that comment in the wrong section as well. 
Tags
Grid
Asked by
Xinzhou
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Xinzhou
Top achievements
Rank 1
Share this question
or