Web svc context menu, ClientState field grows on each postback

4 posts, 0 answers
  1. Greg Chung
    Greg Chung avatar
    48 posts
    Member since:
    Jul 2006

    Posted 01 Oct 2008 Link to this post

    Hi-

    I'm using the Q1 RC for Ajax context menu, populated via web service, in an Ajaxified page.  I have noticed that upon each postback, the (generated) field "RadContextMenu1_ClientState" grows a little larger each time, even if the user never opened the context menu.  My app uses the context menu with no static root menu, based upon the example code posted by Telerik a while back.

    After a number of postbacks, the field will look like this:
    RadContextMenu1_ClientState, size 115 = {"logEntries":[{"Type":3},{"Type":3},{"Type":3},{"Type":3},{"Type":3},{"Type":3},{"Type":3},{"Type":3},{"Type":3}]}

    I need the menu to be re-created via the webservice after every postback, because its state and contents change.  I do NOT include the context menu in the list of updated controls in the Ajax Manager.  Why?  Because even though all I'm doing in the .cs file is removing all the menu items, downloading the empty menu adds about 1.1K to my pagesize.  Therefore, I manually clear out all the menu items during the Ajax Manager handler, onResponseEnd:

        var menu = GetRadContextMenu();
        if (menu.get_persistLoadOnDemandItems())
        {
            menu.trackChanges();
            menu.get_items().clear();
            menu.commitChanges();
            menu._itemsLoaded = false;
        }

    If I try to clean up the menu in the menu's item close handler, it interferes with my handling of the actual menu item click.  The menu works fine in this way EXCEPT that the Client State field just grows and grows by the "{"Type":3}" on each postback.

    I could see no way to control this, except to add a hack to explicitly blank out the value in onResponseEnd():

    form1.RadContextMenu1_ClientState.value = "";


    Telerik, can you explain what's going on?  Am I doing something totally wrong here?

    Many thanks..
  2. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 01 Oct 2008 Link to this post

    Hi Greg Chung,

    Calling menu.trackChanges()  menu.commitChanges() is causing the client-state field to grow. It is constantly logging the "clear" operation (Type:3). If you don't need the changes to be persisted on the server side you should not call the trackChanges() / commitChanges() methods.

    Regards,
    Albert
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Greg Chung
    Greg Chung avatar
    48 posts
    Member since:
    Jul 2006

    Posted 01 Oct 2008 Link to this post

    Thanks for that info.  However, your suggestion does not completely help.  If I don't use track/commit changes, the entire menu seems to be retained somewhere.  My page size increase by several KB every time I open the menu, cumulatively.

    Could this because I'm explicitly clearing the menu, but I am also using PersistLoadOnDemandItems = true ?

  4. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 02 Oct 2008 Link to this post

    Hi Greg Chung,

    If PersistLoadOnDemandItems is set to true RadMenu will call internally track/commitChanges.

    Regards,
    Albert
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top