Jul 01, 2015, 5:38 PM
Out Of Memory in store[GridPanel, ComboBox]
Hi,
I have many difficulties with store component when i use it with a ComboBox, or GridPanel. When i try to load or reload it, i have continually out of memory exception. I don't know what is wrong in my code. For example, in GridPanel in view, i have this statement for reload a grid when i add a new entities
I have many difficulties with store component when i use it with a ComboBox, or GridPanel. When i try to load or reload it, i have continually out of memory exception. I don't know what is wrong in my code. For example, in GridPanel in view, i have this statement for reload a grid when i add a new entities
//Grid of sale lines
X.GridPanel()
.Title("Command lines state")
.Disabled(true)
.MarginSpec("0 0 0 10")
.ID("CommandLinesGrid")
.Flex(1)
.MarginSpec("0 0 0 0")
.Frame(true)
.Collapsible(true)
.Store(
X.Store()
//.RemotePaging(true)
.AutoLoad(false)
.ID("CustomerOderLinesProperties")
.Proxy(
X.AjaxProxy()
.Url(Url.Action("CustomerOderLines","Command"))
.ActionMethods(ac => ac.Read = HttpMethod.POST)
.Reader(X.JsonReader().RootProperty("data"))
)
.Model(
X.Model()
.Fields(
new ModelField() { Name = "CustomerOrderLineID", Type = ModelFieldType.Int },
//new ModelField() { Name = "Product", Type = ModelFieldType.Object },
new ModelField() { Name = "LineOrderPartialPrice", Type = ModelFieldType.Int },
new ModelField() { Name = "LineOrderUnitPrice", Type = ModelFieldType.Int },
new ModelField() { Name = "LineOrderQuantity", Type = ModelFieldType.Int },
new ModelField() { Name = "ProductLabel", Type = ModelFieldType.String },/*
new ModelField() { Name = "PersonSurname", Convert = { Fn = "preparePersonSurname" } },*/
new ModelField() { Name = "LineOrderSellingPrice", Type = ModelFieldType.Int }
)
)
)
.ColumnModel(
X.Column()
.Text("Identifiant")
.DataIndex("CustomerOrderLineID")
.Flex(1)
,
X.Column()
.Text("Product label")
.DataIndex("ProductLabel")
.Flex(1),
X.Column()
.Text("Selling price")
.DataIndex("LineOrderSellingPrice")
.Flex(1)
,
X.Column()
.Text("Quantity")
.DataIndex("LineOrderQuantity")
.Flex(1),
X.Column()
.Text("Partial price")
.DataIndex("LineOrderPartialPrice")
.Flex(1),
X.ImageCommandColumn()
.Width(30)
.Hidden(LoadAction.Utilisateur(MenuAction.DELETE, profile))
.Commands(
X.ImageCommand()
.CommandName("Delete")
.IconCls("icon-broom")
.ToolTip(tt =>
{
tt.Text = "Do you want to delete it?";
tt.Title = "Delete";
}
)
)
.DirectEvents(de =>
{
de.Command.Action = "RemoveCustomerOrderLine";
de.Command.Confirmation.ConfirmRequest = true;
de.Command.Confirmation.Message = Resources.ConfirmDeleteMessage;
de.Command.Confirmation.Title = Resources.ConfirmDeleteTitle;
de.Command.ExtraParams.Add(new Parameter("ID", "record.data.CustomerOrderLineID", ParameterMode.Raw));
de.Command.EventMask.ShowMask = true;
de.Command.EventMask.Msg = Resources.EventMaskMsg;
}),
X.ImageCommandColumn()
.Width(30)
.Hidden(LoadAction.Utilisateur(MenuAction.UPDATE, profile))
.Commands(
X.ImageCommand()
.CommandName("Edit")
.IconCls("icon-edit")
.ToolTip(tt => tt.Text = "Update ?")
)
.DirectEvents(de =>
{
de.Command.Action = "InitializeFields";
de.Command.ExtraParams.Add(new Parameter("ID", "record.data.CustomerOrderLineID", ParameterMode.Raw));
de.Command.EventMask.ShowMask = true;
de.Command.EventMask.Msg = Resources.EventMaskUpdate;
})
)
.BottomBar(
X.PagingToolbar()
)
//End Grid of sale lines
In CommandController, i have this StoreResult that return a list of commad lines for example that has previously add in session //Return command lines of current command
[HttpPost]
public StoreResult CustomerOderLines()
{
List<CustomerOrderLine> customerOrderLine = (List<CustomerOrderLine>)Session["customerOrderLines"];
return this.Store(customerOrderLine);
}
and, when i add a new command line, i call this method of same controller //This method add a CustomerOrderLine in the current Customer's Order
[HttpPost]
public ActionResult AddCustomerOrderLine(CustomerOrderLine customerOderLine)
{
List<CustomerOrderLine> customerOrderLines = (List<CustomerOrderLine>)Session["customerOrderLines"];
if (customerOrderLines != null && customerOrderLines.Count > 0)
{
CustomerOrderLine customerOrderLineExist = customerOrderLines.FirstOrDefault(s => s.ProductID == customerOderLine.ProductID);
if (customerOrderLineExist == null)
{
CustomerOrderLine newArticle = new CustomerOrderLine()
{
CustomerOrderLineID = 1 + customerOrderLines.LastOrDefault().CustomerOrderLineID,
LineOrderUnitPrice = customerOderLine.LineOrderSellingPrice,
LineOrderQuantity = customerOderLine.LineOrderQuantity,
LineOrderSellingPrice = customerOderLine.LineOrderSellingPrice,
ProductID = customerOderLine.ProductID,
Product = _productRepository.Find(customerOderLine.ProductID),
LocalizationID = customerOderLine.LocalizationID,
LineOrderPartialPrice = customerOderLine.LineOrderQuantity * customerOderLine.LineOrderSellingPrice
};
customerOrderLines.Add(newArticle);
}
else
{
customerOrderLineExist.LineOrderQuantity += customerOderLine.LineOrderQuantity;
customerOrderLineExist.LineOrderSellingPrice += customerOderLine.LineOrderSellingPrice;
customerOrderLineExist.LineOrderSellingPrice = customerOrderLineExist.LineOrderQuantity * customerOderLine.LineOrderSellingPrice;
}
}
else
{
customerOrderLines = new List<CustomerOrderLine>();
CustomerOrderLine newArticle = new CustomerOrderLine()
{
CustomerOrderLineID = 1,
LineOrderUnitPrice = customerOderLine.LineOrderSellingPrice,
LineOrderQuantity = customerOderLine.LineOrderQuantity,
LineOrderSellingPrice = customerOderLine.LineOrderSellingPrice,
ProductID = customerOderLine.ProductID,
Product = _productRepository.Find(customerOderLine.ProductID),
LocalizationID = customerOderLine.LocalizationID,
LineOrderPartialPrice = customerOderLine.LineOrderQuantity * customerOderLine.LineOrderSellingPrice
};
customerOrderLines.Add(newArticle);
}
Session["customerOrderLines"] = customerOrderLines;
this.GetCmp<GridPanel>("CommandLinesGrid").Disabled = false;
this.GetCmp<Store>("CustomerOderLinesProperties").Reload();
this.GetCmp<FormPanel>("FormAddCustomerOrderLine").Reset();
this.GetCmp<TextField>("TotalPrice").Hidden = false;
this.GetCmp<TextField>("GridState").Value = 1;
this.GetCmp<TextField>("TotalPrice").Value = customerOrderLines.Select(s => s.LineOrderPartialPrice).Sum();
return this.Direct();
}
Occasionally, it add one command line and when i try to add another, i have this exception or empty error windows. Thank you in advance.
Last edited by kdms; Jul 01, 2015 at 5:41 PM.