[CLOSED] Desktop - saving user configuration and restoring it after login

  1. #1

    [CLOSED] Desktop - saving user configuration and restoring it after login

    Hi,

    I can't find any example discribing/showing how to maintain changes a user might do to desktop page .

    I want to save user configuration (shortcut positions , autorun modules , theme ... ) in DB and restore those settings after user login .
    Is this possible for desktop control . I want to save state for whole default.aspx(desktop) page

    I explored
    http://docs.sencha.com/ext-js/4-0/#!/api/Ext.state.Stateful-cfg-stateful

    but

    i do not know how to implement this ... Any sample would be appreciated

    Thanks
    Last edited by Daniil; Jul 25, 2012 at 2:29 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Unfortunately, we have no such example.

    There are some things I can tell.

    1. You could easily use the built-in Stateful functionality setting up:
    <ext:ResourceManager runat="server" StateProvider="Cookie" />
    and
    <DesktopConfig Stateful="true">
    It will save a state to Cookie and get, respectively, from Cookie.

    Apart from investigating the ExtJS docs, to understand better how it works, I can recommend to investigate the Desktop sources, this file:
    <Ext.NET sources root>\Ext.Net\Build\Ext.Net\ux\desktop\js\Desktop.js
    Please see the getState and applyState functions. As you can see it saves and restores shortcut positions and the quickStart and tray widths.

    Sure, you could extend this functionality.

    2. To save it into Database using the same mechanism you will need to implement your own State Provider.
    http://docs.sencha.com/ext-js/4-1/#!/api/Ext.state.Provider

    3. Or you could just listen respective events, for example, the Desktop ShortcutMove one to save shortcut positions to a database. When restore it on server side setting up respective properties on creation time.
  3. #3
    thanks ,
    this is very helpful
  4. #4

    Desktop customiize

    Hi , I was able to set this option for cookie provider

    I would like to use third option (your suggestion) because I do not understand how to create and use personal provider

    Can you help me to pass ,for example, shortcut position (probably as extraparam) . I was not able to find info about current position

    I Tried something like this

    App.Desktop1.modules[5].shortcut.Y

    Thanks
  5. #5
    The ShortcutMove event is invoked with the following arguments.

    • el - the Desktop
    • module - the Module
    • record - the Shortcut record
    • xy - the new positon


    You could know it setting this:
    <Listeners>
        <ShortcutMove Handler="debugger;" />
    </Listeners>
    and move the shortcut.

    Or just looking at the Page Sources.

    All these arguments you can use to populate ExtraParams. Here is the example.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        class XY
        {
            public int x { get; set; }
            public int y { get; set; }
        }
    
        protected void ShortcutMove(object sender, DirectEventArgs e)
        {
            string moduleId = e.ExtraParams["moduleId"];
            XY xy = JSON.Deserialize<XY>(e.ExtraParams["xy"]);
            string msg = string.Format("module id: {0}</br>x: {1}<br/>y: {2}", moduleId, xy.x, xy.y);
            X.Msg.Alert("ShortcutMove", msg).Show();
        }
    </script>
    
    <!DOCTYPE html>
        
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <ext:ResourceManager runat="server" /> 
    
        <ext:Desktop runat="server">            
            <Modules>
                <ext:DesktopModule ModuleID="Hello" AutoRun="true">
                    <Shortcut Name="Hello" />
                    <Window>
                        <ext:Window runat="server" 
                            Plain="true"
                            Padding="10"
                            Width="150"
                            Height="100"                                                        
                            Title="Greeting" 
                            CloseAction="Destroy" 
                            Maximizable="false" 
                            Minimizable="false">
                            <Content>
                                Welcome to Ext.Net desktop!
                            </Content>
                        </ext:Window>
                    </Window>
                </ext:DesktopModule>
            </Modules>
            <DirectEvents>
                <ShortcutMove OnEvent="ShortcutMove">
                    <ExtraParams>
                        <ext:Parameter Name="moduleId" Value="module.id" Mode="Raw" />
                        <ext:Parameter Name="xy" Value="xy" Mode="Raw" Encode="true" />
                    </ExtraParams>
                </ShortcutMove>
            </DirectEvents>
        </ext:Desktop>
    </body>
    </html>
  6. #6
    could you remove close mark for this thread ...

    Thanks . it helped a lot .is there a way to get all params (Needed for saving state ) in one direct event ?
    for example can I get shortcut position from another event (not shortcut move event )
    having simple button that will handle saving all needed parrams


    I have anther issue :

    code below does not work because
    Ext.Net.X.IsAjaxRequest
    returns
     false
    ( I am using Chrome if it is relevant )
    Protected Sub Default_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Desktop1.Modules(5).Shortcut.SetXY("0", "0")
    I assume I can not call this method in page_load
    I am not sure what AjaxRequest means . Short explanation would be appreciated

    And one more thing

    what should happen when I use ?

    <Listeners>
        <ShortcutMove Handler="debugger;" />
    </Listeners>
    because I do not see any result (where I can see that debugger ) - sorry for probably dumb question . I just started to learn java
    And sorry for bed English ...I hope you can understand me

    Thanks
  7. #7
    Quote Originally Posted by inteligencija View Post
    could you remove close mark for this thread ...
    No problem, done.

    Quote Originally Posted by inteligencija View Post
    is there a way to get all params (Needed for saving state ) in one direct event ?
    for example can I get shortcut position from another event (not shortcut move event )
    having simple button that will handle saving all needed parrams
    I think it is possible. You can send as many parameters as you wish. Sure, taking in the account the AJAX, browser limitations.

    You should go through all shortcuts on client to get its positions.

    Quote Originally Posted by inteligencija View Post
    I have anther issue :

    code below does not work because
    Ext.Net.X.IsAjaxRequest
    returns
     false
    ( I am using Chrome if it is relevant )
    Protected Sub Default_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
             Desktop1.Modules(5).Shortcut.SetXY("0", "0")
    I assume I can not call this method in page_load
    I am not sure what AjaxRequest means . Short explanation would be appreciated
    IsAjaxRequest returns true if DirectEvent/DirectMethod occurs.

    Yes, please use the SetXY method during DirectMethod/DirectEvent only.

    During initial Page_Load you can just set up the X and Y Shortcut properties.

    Quote Originally Posted by inteligencija View Post
    And one more thing

    what should happen when I use ?

    <Listeners>
          <ShortcutMove Handler="debugger;" />
      </Listeners>
    because I do not see any result (where I can see that debugger ) - sorry for probably dumb question
    Generally, "debugger" allows to debug JavaScript. A browser (all special plugin like FireBug for FireFox) stops JavaScript execution and allow to debug JavaScript.

    In this case I recommended it to know the ShortcutMove event arguments.

    When you would move a shortcut, a browser (if it can catch "debugger") should stop JavaScript execution and you would see the names of the arguments.

    Though it is rather easy to look at the Page Sources.

    Quote Originally Posted by inteligencija View Post
    I just started to learn java
    JavaScript :) Java is another language.

    Quote Originally Posted by inteligencija View Post
    And sorry for bed English ...I hope you can understand me
    No problem, you are understandable.
  8. #8
    so how to set icon position when page loads ?
  9. #9
    I think here is the answer.

    Quote Originally Posted by Daniil View Post
    During initial Page_Load you can just set up the X and Y Shortcut properties.
    You should read the saved X,Y from the database and apply them to the Shortcut X,Y properties.
  10. #10
    Thanks . I finally finished this functionality .

    You can mark as Closed now :)

    Again , thanks . you helped me a lot

Similar Threads

  1. How to load dynamic user controls on desktop shortcut?
    By laphuynhkien in forum 2.x Help
    Replies: 4
    Last Post: Aug 23, 2012, 5:58 PM
  2. Replies: 0
    Last Post: Feb 23, 2012, 6:18 AM
  3. [CLOSED] setOpacity error on desktop (after login)
    By CarWise in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jun 21, 2011, 11:39 AM
  4. Replies: 5
    Last Post: Jan 19, 2011, 3:17 PM
  5. Replies: 1
    Last Post: Jul 01, 2010, 1:52 PM

Tags for this Thread

Posting Permissions