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

batch editing max rows limit

1 Answer 250 Views
Grid
This is a migrated thread and some comments may be shown as answers.
shijilesh
Top achievements
Rank 1
shijilesh asked on 17 Dec 2012, 04:41 AM
  
hai i was trying with batch editing , i could retrieve only max 15,000 rows if the count exceeds more than 15,000
nothing is coming  ?? .. please help 


// model 

public partial class ItemMaster
    {
        public string Item_Code { get; set; }
        public string Item_Name { get; set; }
    }


// controller

  public class itemController : Controller
    {
        Entities db = new Entities();

        public ActionResult index()
        {
            return View();
        }

        public ActionResult Editing_Read([DataSourceRequest] DataSourceRequest request)
        {
            return Json(SessionProductRepository.All().ToDataSourceResult(request));
        }

        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Editing_Create([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable<ItemMaster > products)
        {
            var results = new List<ItemMaster >();

            if (products != null && ModelState.IsValid)
            {
                foreach (var product in products)
                {
                    SessionProductRepository.Insert(product);
                    results.Add(product);
                }
            }

            return Json(results.ToDataSourceResult(request, ModelState));
        }

        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Editing_Update([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable<ItemMaster > products)
        {
            if (products != null && ModelState.IsValid)
            {
                foreach (var product in products)
                {
                    var target = SessionProductRepository.One(p => p.Item_Code  == product.Item_Code );
                    if (target != null)
                    {
                        target.Item_Name   = product.Item_Name;
                       
                        SessionProductRepository.Update(target);
                    }
                }
            }            

            return Json(ModelState.ToDataSourceResult());
        }

        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Editing_Destroy([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable<ItemMaster > products)
        {            
            if (products.Any())
            {
                foreach (var product in products)
                {
                    SessionProductRepository.Delete(product);
                }
            }

            return Json(ModelState.ToDataSourceResult());
        }
    }


//SessionProductRepository
 
public class SessionProductRepository
    {  
        public static IList<ItemMaster > All()
        {
            IList<ItemMaster> result = (IList<ItemMaster>)HttpContext.Current.Session["item"];
            if (result == null)
            {
                Entities DB = new Entities();
                HttpContext.Current.Session["item"] = result = DB.ItemMasters;
                    
                 
            }
            return result;
        }
        
        public static ItemMaster One(Func<ItemMaster, bool> predicate)
        {
            return All().Where(predicate).FirstOrDefault();
        }
        
        public static void Insert(ItemMaster product)
        {
            product.Item_Code = All().OrderByDescending(p => p.Item_Code ).First().Item_Code  + 1;
            All().Insert(0, product);
        }
        
        public static void Update(ItemMaster product)
        {
            ItemMaster target = One(p => p.Item_Code  == product.Item_Code );
            if (target != null)
            {
                target.Item_Code = product.Item_Code;
                target.Item_Name  = product.Item_Name; 
            }
        }
        
        public static void Delete(ItemMaster product)
        {
            ItemMaster target = One(p => p.Item_Code  == product.Item_Code);
            if (target != null)
            {
                All().Remove(target);
            }
        }
    }
     
// my view 


@(Html.Kendo().Grid<MvcApplication1.Models.ItemMaster>()    
    .Name("Grid")    
    .Columns(columns => {        
        columns.Bound(p => p.Item_Code );
        columns.Bound(p => p.Item_Name ).Width(140); 
        columns.Command(command => command.Destroy()).Width(110);
    })
    .ToolBar(toolbar => {
        toolbar.Create();
        toolbar.Save();        
    })
    .Editable(editable => editable.Mode(GridEditMode.InCell))
    .Pageable()
    .Sortable()
    .Scrollable()
    .DataSource(dataSource => dataSource
             
        .Ajax()         
        .Batch(true)
        .ServerOperation(false)
        .Events(events => events.Error("error_handler"))
        .Model(model => model.Id(p => p.Item_Code ))
        .Create("Editing_Create", "item")
            .Read("Editing_Read", "item")
            .Update("Editing_Update", "item")
            .Destroy("Editing_Destroy", "item")
    )
)
<script type="text/javascript">
    function error_handler(e) {
        if (e.errors) {
            var message = "Errors:\n";
            $.each(e.errors, function (key, value) {
                if ('errors' in value) {
                    $.each(value.errors, function () {
                        message += this + "\n";
                    });
                }
            });
            alert(message);
        }
    }
</script> 





Posted 11 hours ago (permalink)

hai i was trying with batch editing , i could retrieve only max 15,000 row if count exceeds more than 15,000
nothing is coming  ?? 

Posted 11 hours ago (permalink)

hai i was trying with batch editing , i could retrieve only max 15,000 row if count exceeds more than 15,000
nothing is coming  ?? 

Posted 11 hours ago (permalink)

hai i was trying with batch editing , i could retrieve only max 15,000 row if count exceeds more than 15,000
nothing is coming  ?? 

Posted 11 hours ago (permalink)

hai i was trying with batch editing , i could retrieve only max 15,000 row if count exceeds more than 15,000
nothing is coming  ?? 

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 18 Dec 2012, 09:57 PM
Hi,

There is probably an exception thrown when returning more records by the JavaScriptSerializer because of exceeding the maximum JSON length. In order to avoid it, you should create a custom JSON result and set the serializer MaxJsonLength property to the maximum value. I attached a sample project which demonstrates this scenario.

Regards,
Daniel
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
shijilesh
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or