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>