[CLOSED] Saving state of application elements

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    [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
        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]
  2. #2
    Hi @ingbabic,

    I'll review what might be done.

    Please clarify do you save the state in cookies?
  3. #3
    Yes, sorry I forgot to mention that:
      @Html.X().ResourceManager().StateProvider(StateProvider.Cookie)
  4. #4
    Please specify explicit IDs for all the Columns. Otherwise the state cannot be always restored properly.
  5. #5
    Well... Now it works quite unpredictable. If I for example stretch column and immediately exit application, when next time I start application, the change will not be saved (as opposite to previous situation). If I do change selection between nodes after I do some of column arranging it seems that columns state is remembered and restored, but I had situation where it was not like this (especially if I start app again after some, not long, delay). Unfortunately I did not catch exact scenario, how this does happen. Any way one thing is certain it does NOT work quite :(
  6. #6
    If I for example stretch column and immediately exit application, when next time I start application, the change will not be saved (as opposite to previous situation)
    Please clarify are you sure it didn't happen before? I am pretty much sure setting Columns' IDs should not affect it.

    There is the save delay which is 100 by default. Maybe, the state is not saved if you quickly exit the application.
    http://docs.sencha.com/extjs/5.1/5.1...-cfg-saveDelay

    Please try to set it to 1 or 0, maybe.

Similar Threads

  1. [CLOSED] Saving grid state to database
    By pj_martins in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jan 13, 2012, 3:07 PM
  2. Replies: 2
    Last Post: Dec 07, 2011, 4:37 AM
  3. [CLOSED] Saving grid state using CookieProvider - problem
    By voipswitch in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Aug 11, 2011, 12:44 PM
  4. Replies: 2
    Last Post: Apr 14, 2011, 9:03 AM
  5. Viewport and inner elements
    By unaltro2 in forum 1.x Help
    Replies: 0
    Last Post: Feb 01, 2011, 8:11 AM

Tags for this Thread

Posting Permissions