How to open a link by clicking on a row of DataGrid

I have a list of documents that are available on the internet.  The list is in a XML file that serves as a source of data for a control DataGrid.  What I can't understand is how to open the document selected in the DataGrid control.  I think I need to change something in the service of openDocument (below) but I don't know what I should change.  Any help would be appeciated.

Example of file are below:

Application

viewDocuments.mxml

<? XML version = "1.0" encoding = "utf-8"? >

" < = xmlns:mx mx:Application ' http://www.Adobe.com/2006/MXML "

layout = "absolute".

creationComplete = "initApp (); ">

< mx:Script >

<! [CDATA]

Import mx.collections.ArrayCollection;

Import mx.rpc.events.ResultEvent;

Import mx.core.Application;

[Bindable]

private var documents: ArrayCollection collection;

private function initApp (): void

{

This.srv.Send ();

}

private void onResult(evt:ResultEvent):void

{

This.documents = evt. Result.Data.document;

}

private function openDocument (): void

{

var docURL:String;

docURL = dgDocuments.selectedItem.url;

navigateToURL (new URLRequest ("http://cnn.com/"), '_blank');

Below does not work

navigateToURL (new URLRequest ("docURL"), "_blank");

}

[]] >

< / mx:Script >

< mx:HTTPService id = "srv".

URL = "documents. XML ".

resultFormat ="object"

result = "OnResult (Event)" / >

< mx:Canvas id = "cViewDocumentsContainer".

x = '0 '.

y = '0 '.

Width = '100% '.

Height = "100%" >

< mx:DataGrid id = "dgDocuments".

Width = "600".

height = "186".

dataProvider = "{documents}.

x = "15".

y = "74".

doubleClickEnabled = "true".

doubleClick = "openDocument (); ">

< mx:columns >

< mx:DataGridColumn headerText = "DocID".

dataField = "annual".

Visible = "true" / >

< mx:DataGridColumn headerText = "Name".

dataField = "name".

Visible = "true".

Width = "200" / >

< mx:DataGridColumn headerText = 'Type '.

dataField = "type".

Visible = "true".

Width = "90" / >

< mx:DataGridColumn headerText = "file name".

dataField = "filename".

Visible = "true" / >

< mx:DataGridColumn headerText = "path".

dataField = "url".

Visible = "true" width = "200" / >

< / mx:columns >

< / mx:DataGrid >

< mx:Text x = "10".

y = "10".

Text = "Show Documents"

fontSize = "12".

fontWeight = "bold" / >

< mx:Text x = "15".

y = '48 '.

Text = "double click on the document below you want to read." The document opens in a new window. / >

< / mx:Canvas >

< / mx:Application >

Data

documents. XML

<? XML version = "1.0" encoding = "utf-8"? >

< data >

< document >

< annual > 1 < / annual >

< name > CNN < / name >

URL of < type > < / type >

CNN.com < Filename > < / name of the file >

< url > http://CNN.com/ < / url >

< / document >

< document >

< annual > 2 < / annual >

< name > Yahoo < / name >

URL of < type > < / type >

< file_name > Yahoo.com < / name of the file >

< url > http://Yahoo.com/ < / url >

< / document >

< / data >

Thank you!

Lee

You need this (deletion of the double quotation marks):

navigateToURL)

new URLRequest (docURL), '_blank');

If this post answers your question or assistance, please mark it as such.

Greg Lafrance
www.ChikaraDev.com

Support and Flex development services

Tags: Flex

Similar Questions

  • How to open a link in the browser when clicking on Image?

    I created a clickable image. Now, I want to open a link in the browser when clicking on Image.

    How to get there?

    Call Browser.getDefaultSession () .displayPage (String url)

  • How to open a link automatically in a new tab rather than right click and select open in a new tab?

    no details

    To open a link or bookmark in a new tab, you can:

    • Press the scroll wheel of the mouse over a link or a bookmark
    • Hold down the CTRL key while clicking the link or bookmark

    See:

    If this answer solved your problem, please click 'Solved It' next to this response when connected to the forum.

    Not related to your question, but...

    You may need to update some plug-ins. Check your plug-ins and update if necessary:

  • How to open a link text selected from the keyboard

    I would like to be able to search for text on a screen and then open the link that it connects to. The problem is that I want to do this via the keyboard, i.e. without moving the mouse. It seems that there should be a way to do this. I tried every combination of < meta-key > + back and all combinations of < meta-key > + down arrow I can think, because this seems like a natural place to hide such a shortcut, but nothing helps. Someone knows how to do this?

    Try this extension, and then the Enter key should work:

  • How to open a link in my email that isn't a hyperlink?

    I was sent an email with a very long Web site address.   It if not stressed and I can not open it by clicking on it.   Is there a quick way of opening?

    [Original title: log on to the Web site]

    Hi Antony,

    Access you emails via a Web browser or an email client?

    If the long line of site Web is not a hyperlink, then the sender might not have formatted mail correctly. In this case, the only way to open the link is to copy the link and paste it into a new tab address bar in Internet Explorer.

    Note: Make sure that you open links from shippers of confidence because there is a risk to be directed to malicious Web sites that may install malicious software or other security threats to your computer.

    I hope this helps.

  • How to open a link in the browser of the phone

    I tried to find out how to open links in the browser of the phone, but I'm getting a few surprising opion (StackOverflow) :

    It is not the answer, when you want to continue using PhoneGap Build, but I solved the problem by creating a development environment for Cordova (PhoneGap) on my machine and compile the application locally. In Cordoba 2.5.0 window.open('http://www.myurl.nl', '_system'); works perfectly, it will open the link in the system browser.

    So my advice is to stop using PhoneGap Build and start compiling your application locally.

    I don't know if there is already a good solution that works for all platforms and if I use the Phonegap also supported well build service.

    You ask the Forum of phonegap, but it seems a matter of generation phonegap, the phonegap right build forum is https://forums.adobe.com/community/phonegap/build

    This response seems old, you must use cordova-plugin-inappbrowser to open external links in the browser of the phone

    Install it by adding this line in the config.xml file

    and open the phone's browser with

    cordova.InAppBrowser.open('http://www.myurl.nl','_system');,

  • How to open a link that was received in an e-mail usung microsoft live mail

    I received a number of emails with a link to something else. When I click on that link a box pops up saying "this file does not have a program associated with it for performing this action. Please install a program or, or if it is already installed, create an association in the default programs control panel. "I n 't know how to proceed.  I use Windows 7. Help, please.

    Thank you

    Lanny Fraizer

    If the links do not open a browser window to the referenced page, then this is the browser's file/protocol associations that are confused. I suggest that you (re-) represent Internet Explorer as default browser:
    1. The default type in the start search box, and select default programs results.
    2. Select set your default programs.
    3. In the left pane, select Internet Explorer.
    4. At the foot of the page, click set this program as default.
    5. Click OK.
    6. Select to set the default settings for the access and the computer program.
    7. Select custom , and then click the chevrons pointing to extend the selection.
    8. Under choose a default browser, select Internet Explorer.
    9. For other browsers you use, select enable access to this program .
    10. Click OK, and then restart the computer.
    Now try to click a link in an e-mail. If it still does not work, please describe in detail what is happening, including the full text of the error message.
  • How to open specific links outside htmlLoader?

    I have an Air application, which loads my site through htmlLoader and allows users to connect and interact with it through the app. My problem is I want some links to open outside the application (IE, in the default browser), but I havn't a clue on how to do it. I tried navigateInSystemBrowser in the htmlLoader class, but for some reason, this opens the home page in the default browser and let my application empty. Any ideas?

    Then, you can use references to dom for your links to detect when the user clicks on a link and you can run code to reload the html page (so the linked html page does not load) and you can use navigateToURL.  for example:

    var htmlLoader:HTMLLoader = new HTMLLoader();

    htmlLoader.width = 300;

    htmlLoader.height = 300;

    addChild (htmlLoader);

    htmlLoader.addEventListener (Event.COMPLETE, completeHandler);

    htmlLoader.load (new URLRequest ("http://www.kglad.com/Files/test/menu.html"));

    function completeHandler(event:Event):void {}

    htmlLoader.window.document.getElementsByTagName ("a") [0] .onclick = clickHandler;

    }

    var t:Timer = new Timer (1,1);

    t.addEventListener (TimerEvent.TIMER, reloadF);

    function clickHandler(e:Object):void {}

    t.Start ();

    htmlLoader.removeEventListener (Event.COMPLETE, completeHandler);

    navigateToURL (new URLRequest (htmlLoader.window.document.getElementsByTagName ("a") [0] .href));

    }

    function reloadF(e:TimerEvent):void {}

    htmlLoader.load (new URLRequest ("http://www.kglad.com/Files/test/menu.html"));

    }

  • How to open the link in the background?

    Hey guys.

    I have weird problem. I can't open links from Skype in the background. Every time when I click on the link, wy browser opens and the downloads link. And if should open 3-5-N I should come back to Skype each time.

    Command + click does not work. The middle button on the mouse doesn't work ether.

    I have not found all things related in the settings.

    Could someone help me with way?

    It works in the new version of Skype for Mac, 6.14. You can read the release notes here:

    http://blogs.Skype.com/2014/02/19/Skype-for-Mac-6-14-refining-the-UI/

  • How to open the tab control, clicking on an object?

    Hello

    I have a problem with labview, you can help me?

    I want to open a control object tab to import goods in a table. but, I want to open, when I click on an object like a tank. (in fact, first of all, it is invisible and clicking on the object, will be visible)

    How can I do?

    I think, I can do it with a push button or a switch with the same size to a tank or any object that I use, but with an invisible color! is it possible or new suggestion?

    Best regards


  • How to open a link in the BB native browser from an application with a browser.field on OS 4.6

    Hi all

    I hope this is the right place for this question.

    I develop a widget that works fine on OS 5, but my client requested a 4.6 devices of the OS, so the easy way for us was to make an application that calls a browser.field and load the widget inside files (make some improvements on the css and JS). It works very well.

    Our problem now is that we have a list of items that contains some information like telephone numbers, address and link to a Web site. How can we open this last link on the native blackberry browser? I mean, close the application and open the browser. I need to do it in an html tag, because the link to the web site is located on the page that appears on the browser.field. (just like the tag such for example.)

    I hope that I have explained to me very well and you can understand my problem.

    If anyone has an idea on how to solve this problem, let me know, I'll be really happy.

    In BrowserField, you are notified whenever a user requests a new resource such as browsing to a URL.  You can detect when there is a full qualified URL that is being requested, and then call the BlackBerry browser rather than provide the data flow for the return URL to BrowserField.  At this point, you may also close your application if you wish.

    If the rest of your assets is local, you should probably receive a complete style from the URL for them as an external link and so be able to detect an external link.

  • How to open a link in a new window

    I created a flash site which contains a link to an outside website. When I click on the link, need me that outside Web site in the same browser window. To return to my site, I have to use the arrow to the left. I want to change the link to the external site so that the link opens in a new window. So if someone is going through the link when they finish they can close the window again and the original with my Web site window will remain, without losing them both at the end.

    What I should pay for it?

    var url:URLRequest = new URLRequest("http://www.adobe.com"); navigateToURL(url, "_blank"); 
    
    getURL/navigateToURL
    This method uses the getURL (ActionScript 2.0) or navigateToURL (ActionScript 3.0) command to create a new browser window by targeting a new, blank window. This method is simple, works on all browsers, and requires no JavaScript. This method, however, it does not provide control over window location, size, scrollbars, or toolbars.
    
      I guess something like this you needed?
    
  • How to make a button turn on the 'real' property while I'm clicking on a row of datagrid mxml App flex4

    Hi friends,

    I'm new to flex, I application web flex4 with mxml tags.

    I hit this place, please give an idea.

    I have a DataGrid with 5 lines and 4columns, and also I have a button (enable property is set to false).

    while I click on a particular line of datagrid then the property enbale button should be change to true.

    where I write the code.

    any suggession or the code snippet.

    Thanks in advance.

    B.Venkatesan.

    Hello

    You can take the help of the following code:

    http://ns.Adobe.com/MXML/2009.

    xmlns:s = "library://ns.adobe.com/flex/spark".

    xmlns:MX = "library://ns.adobe.com/flex/mx" minWidth = "955" = "600" minHeight >

    Import mx.collections.ArrayCollection;

    [Bindable]

    public var Arr:ArrayCollection = new collection ArrayCollection ([{a: "AAA", "BBB" b:}, {a: "111", b: "222"}]);

    public void Activate (): void {}

    BTN. Enabled = True;

    }

    ]]>

    Thank you and best regards,
    ------------------------------------------------------------------------------------------ --
    Vibhuti Gosavi . [email protected] | www.infocepts.com
    ------------------------------------------------------------------------------------------ --
  • How to prevent scrolling when you add a new row of datagrid?

    When I addItem to the minion of dataprovider to a datagrid, the datagrid control scrolls automatically to the new line added. Can someone tell me how to prevent scrolling happening, in other words, how to focus on the current line without scrolling of new line. Thank you.

    I didn't know that this was the default behavior.  Anyway, you can save the

    verticalScrollPosition and restore it later.

  • How open the link in a new tab and NOT spend her imidiately?

    How to open a link in a new tab without switching to this imidiately?

    I wrote a custom start (basic HTML) with rel = nofollow links page, so they open in new tabs, but I have to hold the CTRL key so he could open in the background/no swtich him imidiately.

    I also changed browser.tabs.loadDivertedInBackground true (posted by blademasterbobo to an another question/answer)

    I have also installed "Open link in a new tab".

    [Solved]
    "Open link in a new tab" addon has been mucking it upwards. " When I disable the addon, tabs open in the background.

Maybe you are looking for