[CLOSED] GridView, RowContextMenu and dynamic update

  1. #1

    [CLOSED] GridView, RowContextMenu and dynamic update

    Hi,
    I am trying to dynamically update a grid context menu based on an Ajax request.

    All works fine apart from the context menu "flickering" between old-state and new-state since I am activating/deactivating item options.

    Initially I thought to be able to cancel the "RowContextMenU" event by returning false, however it looks like the context menu is always shown despite the return value of the hanlder.

    So, in order to resolve the issue, I was thinking about this possible workaround:
    1) Firstly hide ALL the options, and put a "Loading" fake option when the load takes more than 50 ms
    2) Enable all the options that should be enabled after loading the context menu

    What do you think about this approach?
    Thank you,
    Cheers
    Last edited by Daniil; Sep 10, 2013 at 5:23 AM. Reason: [CLOSED]
  2. #2
    Hi @adrianot,

    Your approach makes sense.

    Though, could you provide a test case to reproduce the initial problem? Maybe, I will be able to come up with something else.
  3. #3
    Hi Daniil,
    thank you for your answer.

    I am currently unable to produce a quick sample of the same, however I've seen that you addressed the RowContextMenu handler cancellation issue on the version 2, since it looks like you provided a BeforeItemContextMenu listener.

    Thanks!
  4. #4
    Yes, there is such an event in v2.

    And yes, RowContextMenu event doesn't support cancellation.

    Please clarify are you using a GridPanel's ContextMenuID?
  5. #5
    Hi Daniil, yes I am using the ContextMenuID to specify the link between the grid and the context menu.
  6. #6
    So, a GridPanel's ContextMenuId feature and its RowContextMenu has no direct relationship. They are independent from each other.

    The ContextMenuId is implemented on the Component level.
    Ext.Component.prototype.initComponent = Ext.Component.prototype.initComponent.createSequence(function () {
        if (!Ext.isEmpty(this.contextMenuId, false)) {
            this.on("render", function () {
                this.el.on("contextmenu", function (e, t) {
                    var menu = Ext.menu.MenuMgr.get(this.contextMenuId);
                    menu.trg = t;
                    e.stopEvent();
                    e.preventDefault();
                    menu.showAt(e.getPoint());
                }, this);            
            }, this, { single : true });    
        }
    You can refuse from ContextMenuId and use a RowContextMenu to show a menu in a similar way. Then it will be easy not to show a menu if needed.
  7. #7
    Thank you Daniil for your suggestion!

Similar Threads

  1. Replies: 0
    Last Post: Apr 22, 2013, 1:20 PM
  2. [CLOSED] How to update dynamic CheckboxGroup
    By stoque in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jun 28, 2011, 8:26 AM
  3. CheckBox Update Problem in Gridview.
    By Ganesh3.shirsath in forum 1.x Help
    Replies: 0
    Last Post: Jan 07, 2011, 9:03 AM
  4. [CLOSED] Dynamic Gridpanel with GridView
    By bethc in forum 1.x Legacy Premium Help
    Replies: 8
    Last Post: Jun 24, 2010, 8:22 AM
  5. How to update a asp.net gridview in ajax callback?
    By tangcan2003 in forum 1.x Help
    Replies: 1
    Last Post: Mar 04, 2009, 11:12 PM

Posting Permissions