[CLOSED] Saving state of application elements

Page 2 of 2 FirstFirst 12
  1. #11
    Only what still does not work is selecting last selected node.
    Please clarify what exactly doesn't work?

    Does GetState save a correct internalId?

    Does the StateRestore try to select the node? What happens in the StateRestore handler?

    Are you sure to rely on a Node's internalId if no Node's ID is set up? I guess an internalId is auto-generated and it might change and the StateRestore won't find a correct Node.
  2. #12
    Please clarify what exactly doesn't work?
    Huh, I thought that you insist on samples that you can copy/paste it in Visual Studio and immediately reproduce problem. Nevertheless I'll explain problem more clearly:
    1. Start sample
    2. Select one of the panels (for example, Astrology)
    3. Select one node in tree (for example Sagittarius)
    4. Exit sample
    5. Start sample again
    6. Now, situation is that sample correctly show last selected panel when I left application, but it doesn't select a node


    Does GetState save a correct internalId?
    yes

    Does the StateRestore try to select the node? What happens in the StateRestore handler?
    No State restore does not select the node. I don't quite understand your second question. Let's go line by line:
    this.collapsed = state.collapsed;
    Here I set collapsed state of panel. It works
    var record = this.getStore().getNodeById(state.selected)
    Here I get correct node, based on selected property saved in get state.
    this.getSelectionModel().select(record)
    Here I'm trying to select that node, but it does not happen (although I've got correct node).

    Are you sure to rely on a Node's internalId if no Node's ID is set up?
    You're right, NodeID is set in second panel, I forgot to set it in first, but for previously mentioned test case it does not have impact.

    Generally I would like is, as you said that there a number of solutions for this problem, your opinion am I doing it on the right way? Maybe there are some more elegant solutions. For example you saw that I set same pieces of code for both accordion panels, which is not so nice especially from perspective of supporting that in future. Could it be done better, with less code and how? Also if this is the only way, why selecting node is not working?
  3. #13
    Huh, I thought that you insist on samples that you can copy/paste it in Visual Studio and immediately reproduce problem.
    Still a verbal explanation helps a lot:) Also we do not always provide a ready solution. Specifically, for experienced Ext.NET developers as you are. Our support also means "pushing into right directions". As well it is not always required for us to run samples. Sometimes it is possible to determine something just looking at the test case and reading the verbal description. In this specific case I was not sure what exactly doesn't work and asked to clarify something.

    Here I'm trying to select that node, but it does not happen (although I've got correct node).
    Okay, now I am almost sure what is going wrong. A node is selected too early.

    As stated in ExtJS docs a ViewReady event should be used to select a default row.
    http://docs.sencha.com/extjs/4.2.1/#...vent-viewready

    So, I would expect this working in a StateRestore handler.
    this.on('viewready', function() {
        this.getSelectionModel().select(record);
    });
    Generally I would like is, as you said that there a number of solutions for this problem, your opinion am I doing it on the right way? Maybe there are some more elegant solutions.
    I think you are on the right way.

    For example you saw that I set same pieces of code for both accordion panels, which is not so nice especially from perspective of supporting that in future.
    I would recommend this approach:
    l.StateRestore.Fn = "onStateRestore"
    g.Fn = "myGetState"
  4. #14
    Well, you said that I am experienced in Ext.NET and I think I am just repetitious, asking silly questions, but I hope I'm not too annoying. Might be that sometimes I'll learn something. This thing with viewready would never come across my mind, simply I because don't know it, because this is too large, I don't know what ever is inside. But at least it works :)

    I hope this one is last question for this thread. When I set
    g.Fn = "getState"
    I do not get anything as parameter in here:
        var getState = function (tree) {
            return { collapsed: tree.collapsed, selected: tree.getSelectionModel().getSelection()[0].internalId };
        }
    My tree is undefined...
    Last edited by ingbabic; Nov 05, 2015 at 2:31 PM.
  5. #15
    Yes, the getState function doesn't have any parameters.
    http://docs.sencha.com/extjs/4.2.1/#...ethod-getState

    Please still use the this reference.

    Well, you said that I am experienced in Ext.NET and I think I am just repetitious, asking silly questions, but I hope I'm not too annoying.
    You are doing very well.

    because this is too large
    True. I always keep forgetting stuff even if I already knew that. Sometimes I found a forum post with my own sample and think like "wow, I already did this before...really?".
  6. #16
    Danill sorry 100x :)
    I am trying to make my samples as simple as possible, but sometimes I go too far. Now everything is working in sample, but real application is having nodes filled via AjaxProxy and it seems that even viewready is too early as tree.getStore().getNodeById(state.selected)
    does not return anything, although state.selected is correct (simply tree is not filled yet with data).

    Do you need sample? :)
  7. #17
    In this scenario selection should be done in a TreeStore's Load listener.
  8. #18
    Ok, still one more problem. StateRestore handler for one tree panel simply doesn't get called. I have checked and rechecked thousand times. Everything is the same for other treepanels in my accordion panel. I am near to start ripping off hair from my head.
  9. #19
    And again, as if by some magic, clearing cookies helped to resolve problem. Thanks a lot Danill. Please close this thread.
Page 2 of 2 FirstFirst 12

Similar Threads

  1. [CLOSED] Saving grid state to database
    By pj_martins in forum 1.x 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 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