How to set a context menu to datagrid?

I have a datagrid that I want to use a contextmenu to remove items. I know how to add a context menu for the datagrid control, but this adds to the whole grid, including the header and the empy list box. I really want the menu to appear when you right-click an item in the list. Could someone please show me an example of how to do this?

Here's what I did-

1 assign the context Menu and methods required for the DataGrid itself as follows: -.

private var deleteRowContextMenuItem:ContextMenuItem;
private var lastRollOverIndex:int;

private function dataGrid_createContextMenuItems():void{
     //DataGrid menu
     var dataGridContextMenu:ContextMenu = new ContextMenu();
     dataGridContextMenu.hideBuiltInItems();

     //Delete Row menu item
     deleteRowContextMenuItem = new ContextMenuItem("Delete Selected Row",false,false);
     deleteRowContextMenuItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,deleteSelectedRow,false,0,true);
     dataGridContextMenu.customItems.push(deleteRowContextMenuItem);

     dataGridContextMenu.addEventListener(ContextMenuEvent.MENU_SELECT,dataGridContextMenu_menuSelect,false,0,true);
     dataGrid.contextMenu = dataGridContextMenu;

}

private function dataGridContextMenu_menuSelect(event:ContextMenuEvent):void{
     //Set the selected row and enable its deletion when using right-click
     dataGrid.selectedIndex = lastRollOverIndex;
     deleteRowContextMenuItem.enabled = true;
}

private function deleteSelectedRow(event:ContextMenuEvent):void{
     if(dataGrid.selectedIndex>-1){
     Alert.show("Delete selected row ("+dataGrid.selectedItem.name+")?",
     "Verification (cannot undo this operation)", Alert.YES|Alert.NO, null, actuallyDeleteSelectedRow);
     }
}

private function actuallyDeleteSelectedRow(event:CloseEvent):void{
     if(event.detail == Alert.YES){
     //// (Code for deleting the selected row from the DataGrid dataProvider) ////
          dataGrid.selectedIndex = -1;
          deleteRowContextMenuItem.enabled = false;
     }
}

2. have the following event on the DataGrid definition - (mx) listener

itemRollOver="{lastRollOverIndex = event.rowIndex}"

It's about everything!

(In any case, this is the solution I did for that matter...)

Tags: Flex

Similar Questions

  • How to customize the context menu in the legend of plotting the graph of wave?

    I am currently on the creation of a simulation of various control loops as educational objectives. Here, I have a chart in waveform to different signals. Now my question, how to customize the context menu in the track of the Waveform graph legend => when I click on 'image' behind the Plotnames one menu to open options where you can customize the color etc. or plotwidth. But students should not have access to these settings. How can I change or disable this menu? The context menu for the waveform graph, I've already customized by right click on table of waveform-Advanced online-online menu, but for the legend of conspiracy, I have not found this setting...

    Thanks for your answers... I tried different things, but I don't see a solution yet :-(

    See you soon

    DCP

    Hi, STC,

    There have been a number of suggestions for change or disable the table , right-click menu, but I see that this does not affect the context menu of legend , which is what you ask for help with.

    To prevent completely the menu right-click to work, you must disable the chart control entirely. You can do this by double-clicking on the chart and select Advanced Options > active state > disabled. This will prevent the operator to be able to generate a menu right click on the chart control.

    If however you still wanted the table, make a right click menu to work, but the legend made a right-click menu will be disabled, I see two options:

    1. draw a classic decoration square on the legend and the transparent color. This will prevent the mouse clicks to achieve the legend, and transparent it will not interfere with your user interface appearance.

    2 use a Structure of the event to capture the event filter Popup Menu of Activation?  for the chart control. You can then use the Coords property to determine if the mouse is over the legend or not. If this is the case, send faithful away? right Terminal. It will refuse the context menu when the user clicks on the legend of the plot.

  • How to use the context menu of the 10 Blackberry in my app using Air

    Hey please help me

    How do I use the native bb 10 context menu, I got contextmenuevent class to access the events, but I don't know how to add the context menu as long press on any image.

    Is there a documentation or extract is available?

    There are several threads on this and can be found from the search field. Here is the one who can answer your question:

    http://supportforums.BlackBerry.com/T5/Adobe-AIR-development/BB10-adding-context-menu-to-list/TD-p/1...

  • How to create the context menu PlayBook under WebWorks

    I searched for hours and I can't find any guidance on how to create a context menu for an application PlayBook WebWorks. I refer the menu which is supposed to appear when you drag to the bottom of the top. I tried to use logical blackberry.ui.menu, but it seems that the functionality of the user interface is not yet available for the PlayBook.

    BlackBerry World, they stressed that it is an important aspect of any application PlayBook so there must be a way to do it. Can someone give me a little push in the right direction?

    -Thanks!

    If you referring to the menu that goes down when a user slips to the bottom of the upper part of the PlayBook, please see this for an example application.

    http://supportforums.BlackBerry.com/T5/Web-and-WebWorks-development/sample-code-swipe-down-menu-for-...

  • How to add custom context menu menu items?

    How to add custom context menu menu items?

    through c++ sdk

    Hi Philippe,.

    to display a context menu you just replace the path of the menu. For example if you have a menu ' hand: & Layout: MyMenu "you can add it to the context menu"RtMouseLayout:MyMenu"in your MenuDef resource in the file en with the ActionID of your ActionComponent.

    Markus

  • How to open the context menu programmatically?

    I'm sure I'm missing something very elementary, but my eyes are listening on after a lot of research.

    I have a set ListField implemented that replaces getContextMenu() and creates a custom context menu.

    I also override trackwheelClick() to intercept clicks when it's to the point. I would like a click wheel to simply open the context menu, but I can't understand how to simulate pressing the menu button.

    Thank you!

    crush makeMenu instead, you can only manage a better

  • How to hide the context menu of a graph?

    Hi all

    I am wondering how or if I could hide the context menu for a table or chart?

    On the attached screenshot menu I want to hide.

    Or is there another possibility to let the user, just edit the balance there and NOT let it activate autoscale?

    You can modify and/or disable the 'Runtime Menu':

  • How to prevent the context menu?

    I have a view of the image that has a context menu that are associated with, and I have a slider that is in addition to that view.

    When I set the cursor, if my finger is placed on a spot for a while, the context menu of the display of the image is raised.

    It is very undesirable.  Is there a way to prevent the opening if the cursor is in interaction with the context menu of the image?

    You can interrupt the opening from the popup menu.

    Here is an example of my code, replace 'condition' by your own condition:

    contextMenuHandler: ContextMenuHandler {
         onPopulating: {
            if (condition) {
               event.abort();
             }
          }
    }
    
  • How to test the context menu bbui.js in ripple?

    IM using bbui.js v0.9.4 and ripple v0.9.10. How to test the context to the ripple manu? When I run the app on DevAlpha long press peek list context menu img, but how to do this in ripple?

    I managed to understand. You must click and hold on the edge/edge of the list of img to get the img to peep context menu. By clicking on the list of img don't peep the context menu.

  • How to fix the context menu on the screen?

    So, I wanted to add a shortcut to the page menu when I press a button.

    I'm following the example of code here Context Menu

    // Create the Container and ActionSet
    Container* contextContainer = new Container();
    ActionSet* actionSet = ActionSet::create()
            .title("Context menu")
            .subtitle("Select an action.");
    
    // Create the ActionItem objects and add them to the ActionSet
    ActionItem* action1 = ActionItem::create()
            .title("First action");
    ActionItem* action2 = ActionItem::create()
            .title("Second action");
    ActionItem* action3 = ActionItem::create()
            .title("Third action");
    actionSet->add(action1);
    actionSet->add(action2);
    actionSet->add(action3);
    
    // Add the ActionSet to the Container
    contextContainer->addActionSet(actionSet);
    

    So how can I actually say that it displays the menu?

    Thank you.  just thinking about it.  wish all first as there are examples.  Arrgg

  • How to remove the context menu buttons?

    Hello

    I have a pretty annoying problem. I have installed GNU Emacs and Emacs W32 some time ago, but spent to vim. However, in the menu context (context menu) for any file text (.txt, .c or .java) it is always an option called "Edit with Emacs." Now, obviously I no longer use Emacs and uninstalled several months ago. However, I can't get rid of this option in the registry. When I click on it now it opens the 'Open with' instead.
    Anyone know how to remove this option from the context menu?
    Thank you!

    Take a look at the app ShellMenuView. See http://www.techspot.com/guides/210-edit-windows-extended-context-menu/ for instructions and download.

  • How to create a context menu on a tree.

    Hello guys.

    Could someone explain to me how can I do to create a context menu on a tree?

    My version of the APEX is 5.0.

    Thanks in advance.

    Edson

    Hi Edson,

    The API for the tree widget and widget menu are undocumented and unsupported at this time.

    Information on the use of the widget menu to display a context menu on interactive reports may be useful for you:

    APEX 5.0 custom Menus | HardLikeSoftware

    The tree widget has an option of contextMenu that integrates with the menu widget.

    Kind regards

    -John

  • How to display the context menu on MAF google map?

    Hi all

    How to show the popup on the google map of the MAF like this? I have a collection of data would appear on the map of google map MAF, but when I click on the screen, I find the popup seems just on the Middle not the style shows as below.

    So I want to know if there is a way to identify the points on the map as the model below. Could you give me some suggestions? Thanks in advance.

    Screen Shot 2014-12-30 at 1.37.23 PM.png

    Byron

    This is supported only from MAF version 2.0.1

    You can use showpopupbehavior within a marker like this:

    shortDesc = "#{row.cityName} '"

    rendering = "true" >

    popupId = "popup1."

    alignId = "marker1 '.

    align = 'topCenter.

    decoration = "anchor" / >

    You can change line property based on your condition.

    In addition, you may need to add the setPropertyListener inside marker as well as to show the current name of the city from the context menu:

    to = "#{pageFlowScope.currentCity} '"

    type = 'action' / >

    Kind regards

    Deepak

  • How to display the context menu using javascript in application of apex

    Hi all

    y at - it someone who has set up a context menu using javascript in its request for apex. We may be able to open other pages I need when clicking on items in the context menu.

    Please answer as soon as possible. I will be very grateful to you all.

    Published by: user12259335 on November 23, 2009 01:18

    Hello
    Sorry, you are right, I don't send you all the :), but I have a request - could you just give me your email address to send you the code.
    Tahnks

  • How to set a checkbox in a datagrid itemrenderer

    Hello.

    I have a spark datagrid. In a column, there is a checkbox. In another column (I need to add dynamically with actionscript), I have another check box (inside an itemrenderer). Cliccking on the first box, I need to toggle the second box.

    More generally, I have need to interact not only with a checkbox, but some other components inside the dynamically added columns.

    My question is: How do I get (with actionscript) components within a dynamically created itemrender?

    Follow the details related to the case of the box:

    Here my datagrid column definitions spark:

    <s:columns>
                        <s:ArrayList>
                                  <s:GridColumn headerText="Azioni" resizable="false" sortable="false" width="49" ....../>
                                  <s:GridColumn headerText="Iscritto" width="60" itemRenderer="renderers.EventoPersonaCheckBoxRenderer" dataField="iscritto"/>
                                  <s:GridColumn id="personaEventoGridPersonaColumn" headerText="Persona" labelFunction...../>
                                  <s:GridColumn id="personaEventoGridSocietaColumn" headerText="Societa" labelFunction..../>
                        </s:ArrayList>
              </s:columns>
    

    As you can see if there's an itemrender. A checkbox is inside.

    I must also add dynamically new columns in my datagrid. Each new column has an itemrender with a checkbox.

    Here the code to add a new column:

    private function createNewColumn():void
                                  {
                                            var newColumn:GridColumn = new GridColumn("column TEST");
                                            newColumn.itemRenderer = new ClassFactory(NewColumnCheckBoxRenderer);
      
                                            var  cols:ArrayList = new ArrayList(); 
      
                                            cols =eventoPersonaGrid.columns as ArrayList;
                                            cols.addItem(newColumn);
                                  }
    

    The itemrenderer is the following:

    <s:GridItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009" 
                                                      xmlns:s="library://ns.adobe.com/flex/spark" 
                                                      xmlns:mx="library://ns.adobe.com/flex/mx" clipAndEnableScrolling="true">
      
              <fx:Script>
                        <![CDATA[
                                  import events.CheckBoxEvent;
      
                                  protected function eventoSubscribedCB_clickHandler(event:MouseEvent):void
                                  {
                                            data.iscritto = ! data.iscritto;
                                            dispatchEvent(new CheckBoxEvent(CheckBoxEvent.UPDATE,data.iscritto));
                                  }
      
                        ]]>
              </fx:Script>
      
              <s:layout>
                        <s:HorizontalLayout horizontalAlign="center" verticalAlign="middle"/>
              </s:layout>
      
              <s:CheckBox id="eventoSubscribedCB" selected="{data.iscritto}" click="eventoSubscribedCB_clickHandler(event)"/>
      
    </s:GridItemRenderer>
    

    As explained above cliccking on the checkbox in datagrid definition, I need to change the properties of the check box that is located inside an itemrenderer.

    How can I do?

    Is there a way to get the itemrenderer and checkbox datagrid selectedItem property references?

    Thank you

    Pbesi

    In general, it is better to access the information contained in the data element or a shared object to determine the visuals for each rendering engine.  If you use the example Checkbox DataGrid spark of my blog, secondary renderers would be turn on or off depending on whether the data element is in the selectedItems.

    --

    Alex Harui

    Flex SDK Team

    Adobe System, Inc..

    http://blogs.Adobe.com/aharui

Maybe you are looking for