Select to view content in your preferred language

how to add new item on the menu option in the attribute table?

4952
6
07-24-2014 11:35 AM
marcostenorio
Emerging Contributor

how to add new item on the menu option in the attribute table?

Como adicionar um novo item no menu opção do widget tabela de attibute?

 

I'm trying to add an option to export to excel.

Eu estou tentando adicionar uma opção para exportar para o Excel.

 

I already have the api as3xls and function, but do not know where to insert.

Tenho a api as3xls e a função pronta, mas não sei onde inserir.

 

someone could indicate which file mxml I change?

Alguém poderia indicar qual arquivo mxml devo alterar?

 

thank you very much.

Muito obrigado.

 

Tenorio

0 Kudos
6 Replies
BjornSvensson
Esri Regular Contributor

The relevant code for that is not in the Flex Viewer source code.  The AttributeTable is an API component and the source code for that is part of the API download.

Inside the zip file, you might want to start looking at

ArcGIS_Flex\src\com\esri\ags\skins\supportClasses\AttributeTableOptionsMenu.mxml

and other Attribute* files in ArcGIS_Flex\src\com\esri\ags\skins\

0 Kudos
marcostenorio
Emerging Contributor

Thank you. I had seen this alternative. insert the button. but was unable to call the function. also was unable to understand the role that exports to csv.

which is sent to this event? heareth and perform the export?

private function exportGroup_clickHandler(event:MouseEvent):void

            {

                dispatchEvent(new Event(EXPORT_TO_CSV));

                remove();

            }

0 Kudos
marcostenorio
Emerging Contributor

to where the event is sent?

who listen and perform the export?

AttributeTableOptionsMenu.mxml

private function exportGroup_clickHandler(event:MouseEvent):void

            {

                dispatchEvent(new Event(EXPORT_TO_CSV));

                remove();

            }

0 Kudos
BjornSvensson
Esri Regular Contributor

It's the AttributeTable API component that listens and performs the export.

0 Kudos
marcostenorio
Emerging Contributor

Jorn, I made the changes listed below, but does not call the function. could help me identify what is missing?

AttributeTableOptionsMenu

public static const EXPORT_TO_XLS:String = "exportToExcel";

private function exportGroup2_clickHandler(event:MouseEvent):void

                  {

                        dispatchEvent(new Event(EXPORT_TO_XLS));

                        remove();

                  }

</s:HGroup>

            <s:HGroup id="exportGroup2"

                          width="100%"

                          buttonMode="true"

click="exportGroup2_clickHandler(event)"

                          verticalAlign="middle">

                  <s:Image width="16" source="@Embed('../../../../../assets/skins/SelectRelatedRecords16.png')"/>

                  <s:Label width="100%"

                              maxDisplayedLines="1"

                              rollOut="label_rollOutHandler(event)"

                              rollOver="label_rollOverHandler(event)"

                              showTruncationTip="true"

                              text="{resourceManager.getString('ESRIMessages', 'exportToExcel')}"/>

AttributeTableWidget

public function exportToExcel(event:MouseEvent):void

                  {                     

                        var dd:Array = new Array ();

            dd= layersUsedInAttributeTable;

                        var sheet:Sheet = new Sheet();

                   

                        var xls:ExcelFile = new ExcelFile();

            xls.sheets.addItem(dd);

                   

                        var bytes: ByteArray = xls.saveToByteArray();

                        var fr:FileReference = new FileReference();

            fr.save(bytes,"ExportExcel.xls");

                  }

0 Kudos
marcostenorio
Emerging Contributor

I tried to use the same logic in existing code

0 Kudos