Detect clicks on a datagrid

Hello
I have the following code...
[code]
<? XML version = "1.0" encoding = "utf-8"? >
"" < mx:Application xmlns:mx = ' http://www.adobe.com/2006/mxml ' layout = "absolute".
creationComplete = "initApp ()" height = "377" width = "572" borderStyle = "solid" > "
< mx:Script > <! [CDATA]
Import mx.collections.XMLListCollection;
Import mx.controls.Alert;
import flash.events.Event
import mx.events.ListEvent
Import mx.events.ListEvent;
[Bindable]
private var _xlcDP:XMLListCollection;




public function initApp (): void
{
var xmlDP:XML =
< data >
< item = quantity of "Potatoes" name = "200" price = "2.50" > < / item >
< item name = "Onions" quantity = price "400" = "3,50" > < / item >
< item name = "Carrots" quantity = price "100" = "4.00" > < / item >
< item = quantity of "Ginger" name = "400" price = "3.00" > < / item >
< = "Eggs" quantity element name = "200" price = "3.00" > < / item >
< = quantity 'Salt' item name = "400" price = "2.50" > < / item >
< item = quantity of 'Sugar' name = "200" price = "2.50" > < / item >
< item name = "Apples" quantity = price "300" = "2.50" > < / item >
< item name = "Banana" quantity = price "40" = "4.00" > < / item >
< item name = "Grapes" quantity = price "300" = "3.00" > < / item >
< / data >
_xlcDP = new XMLListCollection (xmlDP.item);
} //initApp

public function checkvalue (): void {}
{if(Qty.Text=='')}
Alert.Show ("enter the quantity field ', 'Application Error!'")
}
else {}
var selectedtext:String =
var t:Number = Number (qty.text)
var f: Number = t * dgSource.selectedItem.@price
pricedisp. Text = 'RM' + String (f);
}
}
[]] > < / mx:Script >


< mx:NumberValidator source = property '{quantity}' = 'text' invalidCharError = "invalid characters".
minValue = '2' domain = 'int' invalidFormatCharsError = ' only the numbers!
lowerThanMinError = "field cannot have less than 2 RM' trigger ="{mysub}"triggerEvent =" click on "/ >
< mx:Panel x = "10" y = "10" width = "553" height = "357" layout = "absolute" title = 'point Flex' calculating alpha = "1.0" >
< mx:DataGrid id = "dgSource" dataProvider = "{_xlcDP}" editable = "false" = "true" columnWidth = paddingLeft liveScrolling '0' = '20' x = "10" y = "10" active = "true" width "316" = >
< mx:columns >
< mx:Array >
"< mx:DataGridColumn headerText ="Item"dataField="@name "textAlign ="center"/ >
"< mx:DataGridColumn headerText ="Quantity"dataField="@quantity "textAlign ="center"/ >
"< mx:DataGridColumn headerText =" (RM per Kg) price "dataField="@price "textAlign ="center"/ >
< / mx:Array >
< / mx:columns >
< / mx:DataGrid >
< mx:TextInput id = "qty" editable = "true" x = "148" y = "171" width = "71" / >
< mx:Label text = "Enter your quantity" paddingLeft = "20" x = "10" y = "173" / >
< mx:Button label = "Submit" x = "227" y = "171" id = "mysub" click = "checkvalue ()" / >
< mx:VRule x = "334" y = "0" width = "4" height = "317" / >
< mx:TextArea = "346" x = "10" width = "173" height = "297" text = "this simple application calculates the price with quantities and gives you the end result" editable = "false" / >
< mx:Label x = "10" y = "208" text = "point :"/ > "
< mx:Label = "17" x = "230" text = "QTY :"/ > "
< mx:Text = "52" x y = "208" text="{dgSource.selectedItem.@name}"/ >
< mx:Text = "52" x y = '230' text="{dgSource.selectedItem.@quantity}"/ >
< mx:Label = "15" x = "256" text = "New price :"/ > "
< mx:Text = "79" x = "256" id = "pricedisp" enabled = "false" color = "red" / >
< / mx:Panel >
< / mx:Application >
[/ code]

So what I need is to detect if the datagrid control has been clicked, to warn the user to select a row before submitting it, I see that there is a class called ListEvent, but I am unable to use it, as the compiler says that I can not have another public key word (I just copied the code of aid)

How to do?

If nothing has been selected, the DataGrid.selectedIndex will be-1.
Tracy

Tags: Flex

Similar Questions

  • detect clicks on multiple movieclips

    Hello

    Thanks for your time, read this.  I'm hard-pressed to find ways to detect clicks on various movieclips that I'm generation.   Basically, I am allowing to set a number any instances of the same clip.   I would like each instance A) be clickable and B) pass the reference to the click handler.

    For example, I have something like this:

    function addMissile() {}

    this.attachMovie ("missile", "missile" + mtop, this.getNextHighestDepth (), {_x:startx, _y:starty});})

    activeMissiles [mtop] = _root ["missile" + mtop];

    .focusEnabled activeMissiles [mtop] = true;

    Selection.setFocus (activeMissiles [mtop])

    MTop ++

    }

    I would like to add a reminder on click for each of these instances of clip.   Grateful if someone can point me in the right direction

    Best regards

    Tom

    You can use:

    function addMissile() {}

    var mc:MovieClip = this.attachMovie ("missile", "missile" + mtop, this.getNextHighestDepth (), {_x:startx, _y:starty});})

    activeMissiles.push (this ["missile" + mtop]);

    or better yet:

    activeMissiles.push (mc);

    mc.focusEnabled = true;

    Selection.setFocus (mc);

    mc.missileIndex = activeMissiles.length - 1;

    mc.onRelease = function() {}

    trace (this ._name + ":" + this.missileIndex);

    }

    }

  • Detect click trackpad

    Hi, I detect a click on the touchscreen with TouchEvent.DOWN

    but is there a way to detect a trackpad/trackball click event?

    Thank you in advance!

    Too bad! I found the solution!

  • Detect click button close a projector

    Hello world

    My name is Vijay, the India. I used to work with Director MX some time ago, but now had the opportunity to reignite the flame again. I just wanted to know how we can detect that a user has clicked on the close button of the projector. What is the technique for this? My idea is to display another screen just before the projector close to the BONE. I don't expect someone to write the code, but ju

    If you run MX2004 or higher, you can set the real exitLock and be notified of click the closeBox in the Manager "on closeRequest": CloseRequest - Director Online Wiki

  • I'm constantly a msg - malware has been detected, click here to protect your computer. Their icon in my toolbar is, when you bring the cursor, it says protection against spyware.

    I am unable to download something from the microsoft Web site.

    Looks like a rogue program / fake. Start in safe mode / networking. (restart / press / hold down F8). Download malwarebytes , if it is not update installed then do a full scan. Whatever it is, delete it, and then restart

  • Right-click on the question of datagrid

    Hi guys

    I try to get the columnIndex on right-clicking on a datagrid control, so that I can use when I select an item in my custom contextMenu.

    Currently...

    data_grid.addEventListener (ListEvent.ITEM_ROLL_OVER, dataGridRollOver);

    private void dataGridRollOver(event:ListEvent):void {lastRollOverRow = event.index;}  lastRollOverColumn = event.columnIndex; }

    Then I use in my contextMenu feature, lastRollOverRow, and lastRollOverColumn

    It works fine if I right click, select a contextMenu option, then choose another line and repeat etc...

    However, say I decide right click, I clicked on the wrong column, don't choose anything in the contextMenu and then my next action is to right click on the right column - the event listener above does not yet (I guess because the contextMenu has focus), so my vars not updated.

    Is there a way to give focus to the DG on a consecutive right click before re - display the contextMenu?

    I noticed that I don't need to set up an event listener to catch the right click for contextMenu of datagrid. Is there something I can change if I can do something first before the contextMenu pops up?

    Cheers for your help.

    You are in a catch22. The context menu is highest level last chance to Flash for a user to configure the plugin. It's like trying to disable the start menu in Windows. It is designed to have priority. There is no programmatic way in AS3 to hide the context menu, only to change the content. Otherwise people will abuse it.

    I've seen a few attempts at JavaScript/ExternalInterface workaround who work only, but because you're plugins of various natures (ActiveX/Plugin) and the differences between browsers, they can be difficult to make it work properly.

    The only option I have ever had to work was to have JavaScript intercept the click-right, stop the spread (so Flash never received), use ExternalInterface to send an order from JavaScript to Flash with the click information, then have Flash handle.

  • AddEventListener (Event.CHANGE) for Datagrid is?

    Hi everyone, is there an event listener to detect the click of the mouse on which item in datagrid? I'm trying to detect which item the user has clicked in the datagrid control. (my datagrid has as many rows but only 1 column)

    If so, an advise please?

    If you look to the top of the DataGrid class in the Flash help documentation, you will find all the properties, methods, and events that you can use.  Don't forget to include the shared components like the DataGrid has many of the same properties, methods and events, like the other objects that involve selectable inscriptions.

    There is a CHANGE event and a CLICK event and the selectedIndex and selectedItem properties there.  You should be able to work something with those or others that you find listed and explained in the help documents.

  • Is there standard LMB/RMB clicks at the bottom of the touchpad control touchpad area?

    I wanted to buy: http://www.x-kom.pl/p/203762-ultrabook-15-6-hp-envy-15-x360-u000ew-i5-4210u-4gb-1000-win81.html#

    but now I see there no normal touchpad but what does not work as it should in spectrum 13. The case is that each video speak on these new features (which will be obsolete when Windows 9 will happen) not if she still standard LMB/RMB click on.

    Question: If any the Control Zone have touchpade area mechanical mouse left and right button at the bottom of him as all other touchpad?

    I bought the HP ENVY 15-u000ew x 360

    http://WWW8.HP.com/pl/PL/products/laptops/product-detail.html?OID=7270951

    and I'm back just 2 days after purchase. The touchpad is very sticky. It moves in all possible directions in the body of the laptop. Also, it does not detect click LMB and RMB as it should and even sometimes simply do not resposnd at all. Even the body of the display is not uniformly mounted-> it moves on a right side.

    When I bought cheap Acer 1,5 years ago (V3 - 571G) I think this product is very poorly designed, now I see that HP is almost as bad as this V3 - 571G.

  • Alt key + navigation click

    I replaced the navigation click metod for my domain (i.e. a date field) but when you press alt isn't in my metod... I mean navigation alt + click does not call navigationClick metod... why... How to detect click navigation with ALT... I need overrride naviation click on in the case of two presses alt and not hurry...

    Kind regards

    kaddy

    Check if ALT + Pearl click results in the nagivationClick of the screen containing invoked method. It may be that the ALT + click is consumed somewhere between the screen and your field.

  • How to specify that a field in a DataGrid is a URL?

    Hello

    in my datagrid, I have a field that contains a single URL. How to make clickable and open the url in the browser?

    Thank you

    Hello

    protected function dataGrid_itemClickHandler(event:ListEvent):void

    {

    var str:String is dataGrid.columns [event.columnIndex] .dataField;.

    Switch (STR)

    {

    ' name ':

    getServeurByNameResult.token = serveurService.getServeurByName (event.itemRenderer.data.nom);

    break;

    case 'website:

    navigateToURL (new URLRequest (event.itemRenderer.data.siteweb), '_blank');

    break;

    }

    }

    Now you can update the second grid if you click the name cell and got to the url if you click the cell of Web site.
    You may click on the DataGrid to use itemClick event instead.
    itemClick = "dataGrid_itemClickHandler (event)" "
    creationComplete = "dataGrid_creationCompleteHandler (event)" "
    dataProvider = "{getAllServeurResult.lastResult}" > "
    David.
  • Flex4 DataGrid - mouse outside the data keeps scrolling DataGrid grid

    Hello

    the DataGrid control has the following behavior: when you click on the DataGrid control and move the mouse upwards on top of it and hold the mouse on top of it, the guard UPWARDS scrolling DataGrid control. When you move the mouse under the bottom of the data grid, the DataGrid scroll guard DROP.

    I am optimize my app for touch devices, and when the user moves his finger on the DataGrid from the bottom to the top, I left the DataGrid scroll in the same direction, which is in DECLINE. If the user now moves his finger beyond the upper limit of the data grid, the DataGrid changes the direction of scrolling.

    How can I avoid scrolling the DataGrid when the mouse moves outside, or how change the direction of scrolling the DataGrid?

    Thanks in advance

    LLD

    You can have to subclass DataGrid and override the dragScroll method.

  • How to restrict user access mutiple clicks with asynchrounous behavior of FLEX

    I developed a flex application and it has a datagrid control, and double click on the DataGrid, I show a pop-up window (the code in the pop-up window to call httpService.send () to get the data and display). Before the popup is open, the user is double clicking again on the data grid, which inturn is trying to open the pop-up window (with a new call to the web service). These calls are piling up. How can I limit using httpService.send () when the user double clicked for the second time on the datagrid control. Since then, call web service async by nature, I'm not able to find a way to do this. Can someone please help.

    set

    This.Enabled = false;

    After the service.

    and in the event of failure/result.

    This.enabled = true;

    Yet, all things BUSYCURSOR, because referring the good user.

  • Restoration of sorting in dataGrid

    After the user saves the data I am refreshing dataGrid by pulling the data from the server. Once the dataProvider is reassigned, previously set sorting disappeared. How to restore the sort (if any) after setting the dataProvider?

    Thank you

    I imagine that the datagrid control is set to zero when you reassign its dataProvider.

    If you use a single instance of XMLListCollection as the dataProvider

    for the grid and assign your XML data to the XMLListCollection

    the property 'source', your data updates without resetting the grid.

    Here is a very simple example:


    <>
    "xmlns:MX ="http://www.adobe.com/2006/mxml"
    Layout = "vertical".
    creationComplete = "setDataProvider ()" > "
      
      
          Import mx.collections.XMLListCollection;
            
    [Bindable]
    private var xmlOriginal: XML =
               
                  
                  
                  
                  
               

               
    private var xmlUpdated: XML =
               
                  
                  
                  
                  
                  
               
      
            
    private void setDataProvider(): void
    {
    dataGrid.dataProvider = new XMLListCollection (xmlOriginal.. agenda);
    }
            
    ]]>
      

      
       <>
    ID = "dataGrid" / >
      
       <>
    label = "Simulate the update"
    a click = ".source XMLListCollection (dataGrid.dataProvider) ' = xmlUpdated... agenda" / > "
      

  • Is there a way to select the current row of the datagrid

    It seems when they right click a row in a datagrid, it calls the context menu events. I added a menu right click of my datagrid, however, until the user left clicks on a line I can not say what rank they have chosen.

    Is it possible to determine which line they clicked on with a right cilck? I can't force them to left click and right click, then, it would be terrible...

    I found the answer here

    http://blog.flexexamples.com/2007/08/20/using-a-custom-context-menu-with-the-Flex-DataGrid - control.

    It is the key to all this. In my definition of datagrid, I set the following...

    itemRollOver = "{lastRollOverIndex = event.rowIndex - 1}" "

  • List with a DataGrid

    Hello

    I'm just rephrase the same mission in a different way. Is it possible to have a list on a datagrid rendering engine?, I want to show a list of items when I click on a datagrid column. And I want to update on the grid selection

    I have the MXML ready for the grid, and I also also realized renderer component. I don't know how to call from within the datagrid control.

    Suppose I have the component, how to call it?

    < mx:DataGridColumn headerText = "Status" dataField = 'active' itemEditor = "mx.controls.List"
    editorDataField = "value" rendererIsEditor = "true" / >

    or should I use
    < mx:DataGridColumn headerText = "Status" dataField = 'active' itemEditor = "component/MyComponent.
    editorDataField = "value" rendererIsEditor = "true" / >

    I tried to find help, should I use IDropInListItemRenderer interface? They show it to other controls and no list...


    Any help will be appreciated.

    Thank you!

    Here is your new component 'list ':


    http://www.Adobe.com/2006/mxml">

    1 true
    2 fake
    3. not required

    Secondly,.

    public void checkedit(event:DataGridEvent):void
    {
    if(Event.DataField=="active")<-- what="" is="">
    {
    Event.preventDefault)
    Alert.Show ("this section is not editable, please select from the list", "Flex Alert");
    }

    the if condition in this method would be always true for the status column. and Event.preventDefault () would keep dropdown to appear. You must change this setting to correct the condition. meawhile, comment just these two line within the if block and see it in action.

    Finally, what you are trying to do here doesn't have much sense!

    private void checkit(Myevent:Event):void
    {
    mydg.invalidateDisplayList)
    }

    I hope this helps.

    ATTA

Maybe you are looking for

  • Keychain, iCloud + problems of Photos on MBPro since changed password and password set firmware

    Hello I recently changed the password for the connection on my main account on my MBPro and added a firmware password, but that doesn't seem to work properly: whenever I reboot Keychain keeps asking me to access the local keychain and all iCloud apps

  • How can I make iOS rescan my photo library, searching for old memories?

    When I used iOS 10 beta publice photos do a scan on my photo library in the background. Then I went back to iOS 9.3.2 after that I installed iOS 10 once the same memories where it so I deleted them in DSB to make the photo scan my photo library app o

  • Re: Satellite A100 recovery media

    Where can I purchase/download the recovery for a Satellite A100 media?

  • When I install iTunes Windows Installer closes

    I just installed Windows 10 Pro x 64 and am trying to install iTunes, but every time I try to install the windows installer just closes. All I see is the Green loading bar when you open the executable first, but this is when it crashes. Help is appre

  • Pavilion dm4: boot disk

    Ive had my Pavilion dm4 for a few years and I had stopped using it because as my hard drive broke and I needed a new. I recently got a new hard drive and installed but when I turn on the computer, it says I need to insert a boot disk, and then press