Oct 30, 2015, 9:52 AM
[CLOSED] Saving state of application elements
Hello
In following sample when you select one of the tree nodes, grid is shown in central panel. When you resize columns, change their position, or visibility, close application and then open it again, changes will be saved and columns will be displayed as user arranged them. So far so good. Problem is when you click between nodes. Nothing is remembered then and grid is shown with no regard to user changes.
I tried similar technique for remembering last selected accordion panel and last selected node but it does not work at all :(
How that would be possible?
index.cshtml
In following sample when you select one of the tree nodes, grid is shown in central panel. When you resize columns, change their position, or visibility, close application and then open it again, changes will be saved and columns will be displayed as user arranged them. So far so good. Problem is when you click between nodes. Nothing is remembered then and grid is shown with no regard to user changes.
I tried similar technique for remembering last selected accordion panel and last selected node but it does not work at all :(
How that would be possible?
index.cshtml
Html.X().Panel().Layout(LayoutType.Border).Border(false).Height(600)
.Items
(
Html.X().Panel().Title("Components").Region(Region.West).Layout(LayoutType.Accordion).Width(200)
.Items
(
Html.X().TreePanel().Title("Codebooks")
.Root
(
Html.X().Node().Text("Codebooks").Expanded(true)
.Children
(
Html.X().Node().Text("Countries").Leaf(true),
Html.X().Node().Text("Cities").Leaf(true)
)
)
.DirectEvents(de =>
{
de.SelectionChange.Url = "ShowCodebook";
de.SelectionChange.ExtraParams.Add(new Parameter("codebook", "selected.length>0 ? selected[0].data.text: ''", ParameterMode.Raw));
}),
Html.X().TreePanel().Title("Astrology")
.Root
(
Html.X().Node().Text("Signs").Expanded(true)
.Children
(
Html.X().Node().Text("Aries").Leaf(true),
Html.X().Node().Text("Taurus").Leaf(true),
Html.X().Node().Text("Gemini").Leaf(true),
Html.X().Node().Text("Cancer").Leaf(true),
Html.X().Node().Text("Leo").Leaf(true),
Html.X().Node().Text("Virgo").Leaf(true),
Html.X().Node().Text("Libra").Leaf(true),
Html.X().Node().Text("Scorpio").Leaf(true),
Html.X().Node().Text("Sagittarius").Leaf(true),
Html.X().Node().Text("Capricorn").Leaf(true),
Html.X().Node().Text("Aquarius").Leaf(true),
Html.X().Node().Text("Pisces").Leaf(true)
)
)
)
,
Html.X().Panel().ID("Center1").Region(Region.Center).Title("Main").Layout(LayoutType.Fit)
)
Codebook.cshtml@model string
@(
Html.X().GridPanel().Title(Model).Stateful(true).StateID("grid_" + Model).StateEvents(new string[] { "columnresize", "columnmove", "columnvisible", "columnsort" })
.ColumnModel
(
c =>
{
if (Model == "Countries")
{
c.Columns.Add(Html.X().Column().Text("Country name"));
c.Columns.Add(Html.X().Column().Text("Area"));
c.Columns.Add(Html.X().Column().Text("Inhabitans"));
c.Columns.Add(Html.X().Column().Text("BDP"));
c.Columns.Add(Html.X().DateColumn().Text("President"));
}
else
{
c.Columns.Add(Html.X().Column().Text("City name"));
c.Columns.Add(Html.X().Column().Text("Area"));
c.Columns.Add(Html.X().Column().Text("Inhabitans"));
c.Columns.Add(Html.X().Column().Text("Country"));
c.Columns.Add(Html.X().DateColumn().Text("Major"));
}
}
)
)
Controller public ActionResult Index()
{
return View();
}
public ActionResult ShowCodebook(string codebook)
{
return new Ext.Net.MVC.PartialViewResult
{
ViewName = "Codebook",
Model = codebook,
ContainerId = "Center1",
ClearContainer = true,
RenderMode = RenderMode.AddTo
};
Last edited by Daniil; Nov 07, 2015 at 8:13 AM.
Reason: [CLOSED]