<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: 3.2 Attribute Table copy in ArcGIS Viewer for Flex Questions</title>
    <link>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/3-2-attribute-table-copy/m-p/731699#M22040</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;That's handy but just doesn't cut it (pun intended). My users want a simple Ctrl+C just like how Excel works. Here's an extension I wrote to illustrate.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;
&amp;lt;!--
AttributeTableWidget extension for ArcGIS Flex Viewer 3.2
Adds copy feature to Attribute Table via keyboard and right-click menu.
To use, configure the AttributeTable widget and substitute this file for "AttributeTableWidget.mxml" in your config.xml
--&amp;gt;
&amp;lt;AttributeTable:AttributeTableWidget xmlns:fx="http://ns.adobe.com/mxml/2009"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:AttributeTable="widgets.AttributeTable.*"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; widgetConfigLoaded="basewidget_widgetConfigLoaded()"&amp;gt;

 &amp;lt;fx:Script&amp;gt;
&amp;nbsp; &amp;lt;![CDATA[
&amp;nbsp;&amp;nbsp; import com.esri.ags.Graphic;
&amp;nbsp;&amp;nbsp; import com.esri.ags.components.AttributeTable;

&amp;nbsp;&amp;nbsp; import flash.events.ContextMenuEvent;

&amp;nbsp;&amp;nbsp; import spark.components.NavigatorContent;


&amp;nbsp;&amp;nbsp; /** Listen for new AttributeTables being added to viewStack */
&amp;nbsp;&amp;nbsp; private function basewidget_widgetConfigLoaded():void
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; viewStack.addEventListener(ChildExistenceChangedEvent.CHILD_ADD, childAddEvent);
&amp;nbsp;&amp;nbsp; }

&amp;nbsp;&amp;nbsp; /** Add copy listener and menu item to the new AttributeTable */
&amp;nbsp;&amp;nbsp; private function childAddEvent(event:ChildExistenceChangedEvent):void
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; var attributeTable:AttributeTable = (event.relatedObject as NavigatorContent).getElementAt(0) as AttributeTable;

&amp;nbsp;&amp;nbsp;&amp;nbsp; attributeTable.addEventListener(Event.COPY, attributeTable_copyHandler);

&amp;nbsp;&amp;nbsp;&amp;nbsp; var contextMenu:ContextMenu = new ContextMenu();
&amp;nbsp;&amp;nbsp;&amp;nbsp; contextMenu.hideBuiltInItems();
&amp;nbsp;&amp;nbsp;&amp;nbsp; var customItem:ContextMenuItem = new ContextMenuItem("Copy selected");
&amp;nbsp;&amp;nbsp;&amp;nbsp; customItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, customItem_menuItemSelectHandler);
&amp;nbsp;&amp;nbsp;&amp;nbsp; contextMenu.customItems.push(customItem);
&amp;nbsp;&amp;nbsp;&amp;nbsp; attributeTable.contextMenu = contextMenu;
&amp;nbsp;&amp;nbsp; }

&amp;nbsp;&amp;nbsp; /** Copy selected rows to the clipboard Excel style */
&amp;nbsp;&amp;nbsp; private function attributeTable_copyHandler(event:Event):void
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; var rows:Array = [];
&amp;nbsp;&amp;nbsp;&amp;nbsp; for each (var graphic:Graphic in (event.currentTarget as AttributeTable).featureLayer.selectedFeatures)
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var newRow:Array = [];
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for each (var value:String in graphic.attributes)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newRow.push(value);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.push(newRow.join("\t"));
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; System.setClipboard(rows.join("\r\n"));
&amp;nbsp;&amp;nbsp; }

&amp;nbsp;&amp;nbsp; /** Dispatch a COPY event when clicked */
&amp;nbsp;&amp;nbsp; private function customItem_menuItemSelectHandler(event:ContextMenuEvent):void
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; (event.contextMenuOwner as AttributeTable).dispatchEvent(new Event(Event.COPY));
&amp;nbsp;&amp;nbsp; }
&amp;nbsp; ]]&amp;gt;
 &amp;lt;/fx:Script&amp;gt;
&amp;lt;/AttributeTable:AttributeTableWidget&amp;gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It'd be great to have a similar capability in a future release. This code is retyped, so I apologize in advance for any typos.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 07:14:03 GMT</pubDate>
    <dc:creator>KennyHoran</dc:creator>
    <dc:date>2021-12-12T07:14:03Z</dc:date>
    <item>
      <title>3.2 Attribute Table copy</title>
      <link>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/3-2-attribute-table-copy/m-p/731697#M22038</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;My users like the Attribute Table but they'd really like to copy data from the Attribute Table and paste it elsewhere.&amp;nbsp; Might I place an enhancement request for this feature?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Alternately I see an Event.COPY event fires on the Attribute Table when a user presses Ctl+C, but now I'm stuck on how to get at the data.&amp;nbsp; How do I access the selected items in an Attribute Table?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Edit: Found the selected items in AttributeTable.featureLayer.selectedFeatures&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Apr 2013 14:46:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/3-2-attribute-table-copy/m-p/731697#M22038</guid>
      <dc:creator>KennyHoran</dc:creator>
      <dc:date>2013-04-22T14:46:47Z</dc:date>
    </item>
    <item>
      <title>Re: 3.2 Attribute Table copy</title>
      <link>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/3-2-attribute-table-copy/m-p/731698#M22039</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hey Kenny,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you look under the 'Table Options' menu, there is a way to export the data to a CSV file. If there are any features selected it would only export those, otherwise the entire feature set.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Apr 2013 21:23:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/3-2-attribute-table-copy/m-p/731698#M22039</guid>
      <dc:creator>SarthakDatt</dc:creator>
      <dc:date>2013-04-23T21:23:10Z</dc:date>
    </item>
    <item>
      <title>Re: 3.2 Attribute Table copy</title>
      <link>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/3-2-attribute-table-copy/m-p/731699#M22040</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;That's handy but just doesn't cut it (pun intended). My users want a simple Ctrl+C just like how Excel works. Here's an extension I wrote to illustrate.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;
&amp;lt;!--
AttributeTableWidget extension for ArcGIS Flex Viewer 3.2
Adds copy feature to Attribute Table via keyboard and right-click menu.
To use, configure the AttributeTable widget and substitute this file for "AttributeTableWidget.mxml" in your config.xml
--&amp;gt;
&amp;lt;AttributeTable:AttributeTableWidget xmlns:fx="http://ns.adobe.com/mxml/2009"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:AttributeTable="widgets.AttributeTable.*"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; widgetConfigLoaded="basewidget_widgetConfigLoaded()"&amp;gt;

 &amp;lt;fx:Script&amp;gt;
&amp;nbsp; &amp;lt;![CDATA[
&amp;nbsp;&amp;nbsp; import com.esri.ags.Graphic;
&amp;nbsp;&amp;nbsp; import com.esri.ags.components.AttributeTable;

&amp;nbsp;&amp;nbsp; import flash.events.ContextMenuEvent;

&amp;nbsp;&amp;nbsp; import spark.components.NavigatorContent;


&amp;nbsp;&amp;nbsp; /** Listen for new AttributeTables being added to viewStack */
&amp;nbsp;&amp;nbsp; private function basewidget_widgetConfigLoaded():void
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; viewStack.addEventListener(ChildExistenceChangedEvent.CHILD_ADD, childAddEvent);
&amp;nbsp;&amp;nbsp; }

&amp;nbsp;&amp;nbsp; /** Add copy listener and menu item to the new AttributeTable */
&amp;nbsp;&amp;nbsp; private function childAddEvent(event:ChildExistenceChangedEvent):void
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; var attributeTable:AttributeTable = (event.relatedObject as NavigatorContent).getElementAt(0) as AttributeTable;

&amp;nbsp;&amp;nbsp;&amp;nbsp; attributeTable.addEventListener(Event.COPY, attributeTable_copyHandler);

&amp;nbsp;&amp;nbsp;&amp;nbsp; var contextMenu:ContextMenu = new ContextMenu();
&amp;nbsp;&amp;nbsp;&amp;nbsp; contextMenu.hideBuiltInItems();
&amp;nbsp;&amp;nbsp;&amp;nbsp; var customItem:ContextMenuItem = new ContextMenuItem("Copy selected");
&amp;nbsp;&amp;nbsp;&amp;nbsp; customItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, customItem_menuItemSelectHandler);
&amp;nbsp;&amp;nbsp;&amp;nbsp; contextMenu.customItems.push(customItem);
&amp;nbsp;&amp;nbsp;&amp;nbsp; attributeTable.contextMenu = contextMenu;
&amp;nbsp;&amp;nbsp; }

&amp;nbsp;&amp;nbsp; /** Copy selected rows to the clipboard Excel style */
&amp;nbsp;&amp;nbsp; private function attributeTable_copyHandler(event:Event):void
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; var rows:Array = [];
&amp;nbsp;&amp;nbsp;&amp;nbsp; for each (var graphic:Graphic in (event.currentTarget as AttributeTable).featureLayer.selectedFeatures)
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var newRow:Array = [];
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for each (var value:String in graphic.attributes)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newRow.push(value);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.push(newRow.join("\t"));
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; System.setClipboard(rows.join("\r\n"));
&amp;nbsp;&amp;nbsp; }

&amp;nbsp;&amp;nbsp; /** Dispatch a COPY event when clicked */
&amp;nbsp;&amp;nbsp; private function customItem_menuItemSelectHandler(event:ContextMenuEvent):void
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; (event.contextMenuOwner as AttributeTable).dispatchEvent(new Event(Event.COPY));
&amp;nbsp;&amp;nbsp; }
&amp;nbsp; ]]&amp;gt;
 &amp;lt;/fx:Script&amp;gt;
&amp;lt;/AttributeTable:AttributeTableWidget&amp;gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It'd be great to have a similar capability in a future release. This code is retyped, so I apologize in advance for any typos.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:14:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-viewer-for-flex-questions/3-2-attribute-table-copy/m-p/731699#M22040</guid>
      <dc:creator>KennyHoran</dc:creator>
      <dc:date>2021-12-12T07:14:03Z</dc:date>
    </item>
  </channel>
</rss>

