Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9016431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:59:39+00:00 2026-06-16T03:59:39+00:00

The question: I have an accordion with 3 index’s, each containing a component. That

  • 0

The question:
I have an accordion with 3 index’s, each containing a component. That component is always the same one (an ordinary datagrid). This datagrid receives his data through php and JSON.

Now when the SelectedIndex of my accordeon changes, the data in my datagrid should change.

this is the php query:

$query = "SELECT * FROM gerecht where typeID = " . $typeId;

where $typeId is the selectedIndex

if(isset($_POST['accIndex'])){
    $typeId = mysql_real_escape_string($_POST['accIndex']);
} else {
    $typeId = 1;
}

Now whenever I change the accordion-index, the data stays the same. Here is my flex code:

    <?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" xmlns:components="components.*" initialize="getData.send();">
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
        <mx:HTTPService id="getData" url="http://localhost/P006_Project/Query.php" 
                        useProxy="false" method="POST" resultFormat="text" result="getPHPData(event)" />
        <mx:HTTPService id="sendData" url="http://localhost/P006_Project/Query.php"
                        useProxy="false" method="POST" result="sendData_resultHandler(event)">
            <mx:request xmlns="">
                <accIndex>
                    {accItems.selectedIndex + 1}
                </accIndex>
            </mx:request>
        </mx:HTTPService>

        <s:ArrayCollection id="acItems" source="{dataArray.source}" />
    </fx:Declarations>
    <fx:Script>
        <![CDATA[
            import mx.collections.ArrayCollection;
            import mx.controls.Alert;
            import mx.controls.Text;
            import mx.events.FlexEvent;
            import mx.events.IndexChangedEvent;
            import mx.rpc.events.ResultEvent;

            [Bindable]private var dataArray:ArrayCollection = new ArrayCollection();

            private function initDataGrid():void
            {
                getData.send();
            }

            private function getPHPData(event:ResultEvent):void
            {
                var rawArray:Array;
                var rawData:String = String(event.result);
                rawArray = JSON.parse(rawData) as Array;
                dataArray = new ArrayCollection(rawArray);
            }

            protected function accItems_changeHandler(event:IndexChangedEvent):void
            {
                // TODO Auto-generated method stub
                sendData.send();
                trace(acItems);
            }

            protected function sendData_resultHandler(event:ResultEvent):void
            {
                // TODO Auto-generated method stub
                Alert.show(event.result.toString());
            }

        ]]>
    </fx:Script>

    <mx:Accordion id="accItems" creationPolicy="auto" change="accItems_changeHandler(event)">
        <s:NavigatorContent label="Frisdranken">
            <components:FULLTESTCOMP acItems="{acItems}" creationComplete="{initDataGrid()}"/>
        </s:NavigatorContent>
        <s:NavigatorContent label="Bieren (vat)">
            <components:FULLTESTCOMP acItems="{acItems}" creationComplete="{initDataGrid()}"/>
        </s:NavigatorContent>
    </mx:Accordion>
</s:Application>

I’m guessing something is going wrong either in:
– php receiving the selectedIndex?
– or flex is not able to update the datagrid with the new data?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T03:59:40+00:00Added an answer on June 16, 2026 at 3:59 am

    K I finally found the solution. I was using 2 httpServices, I was alwayys receiving the data from the first one, but this one did not contain a parameter. So I merged both of them in one. Resulting in the following code: (I also added all of my other components so don’t pay attention to them)

    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
                   xmlns:s="library://ns.adobe.com/flex/spark" 
                   xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" xmlns:components="components.*">
        <fx:Declarations>
            <!-- Place non-visual elements (e.g., services, value objects) here -->
            <mx:HTTPService id="sendData" url="http://localhost/P006_Project/Query.php"
                            useProxy="false" method="POST" result="sendData_resultHandler(event)">
                <mx:request xmlns="">
                    <accIndex>
                        {accItems.selectedIndex + 1}
                    </accIndex>
                </mx:request>
            </mx:HTTPService>
    
            <s:ArrayCollection id="acItems" source="{dataArray.source}" />
        </fx:Declarations>
        <fx:Script>
            <![CDATA[
                import mx.collections.ArrayCollection;
                import mx.controls.Alert;
                import mx.controls.Text;
                import mx.events.FlexEvent;
                import mx.events.IndexChangedEvent;
                import mx.rpc.events.ResultEvent;
    
                [Bindable]private var dataArray:ArrayCollection = new ArrayCollection();
    
                private function initDataGrid():void
                {
                    sendData.send();
                }
    
                protected function accItems_changeHandler(event:IndexChangedEvent):void
                {
                    sendData.send();
                }
    
                protected function sendData_resultHandler(event:ResultEvent):void
                {
                    var rawArray:Array;
                    var rawData:String = String(event.result);
                    rawArray = JSON.parse(rawData) as Array;
                    dataArray = new ArrayCollection(rawArray);
                }
    
            ]]>
        </fx:Script>
    
        <mx:Accordion id="accItems" creationPolicy="auto" change="accItems_changeHandler(event)">
            <s:NavigatorContent label="Frisdranken">
                <components:FULLTESTCOMP acItems="{acItems}" creationComplete="{initDataGrid()}"/>
            </s:NavigatorContent>
            <s:NavigatorContent label="Bieren (vat)">
                <components:FULLTESTCOMP acItems="{acItems}" creationComplete="{initDataGrid()}"/>
            </s:NavigatorContent>
            <s:NavigatorContent label="Bieren">
                <components:FULLTESTCOMP acItems="{acItems}" creationComplete="{initDataGrid()}"/>
            </s:NavigatorContent>
            <s:NavigatorContent label="Warme dranken">
                <components:FULLTESTCOMP acItems="{acItems}" creationComplete="{initDataGrid()}"/>
            </s:NavigatorContent>
            <s:NavigatorContent label="Wijnen">
                <components:FULLTESTCOMP acItems="{acItems}" creationComplete="{initDataGrid()}"/>
            </s:NavigatorContent>
            <s:NavigatorContent label="Sterke dranken">
                <components:FULLTESTCOMP acItems="{acItems}" creationComplete="{initDataGrid()}"/>
            </s:NavigatorContent>
            <s:NavigatorContent label="Tapas">
                <components:FULLTESTCOMP acItems="{acItems}" creationComplete="{initDataGrid()}"/>
            </s:NavigatorContent>
            <s:NavigatorContent label="Platos">
                <components:FULLTESTCOMP acItems="{acItems}" creationComplete="{initDataGrid()}"/>
            </s:NavigatorContent>
            <s:NavigatorContent label="Especialidades">
                <components:FULLTESTCOMP acItems="{acItems}" creationComplete="{initDataGrid()}"/>
            </s:NavigatorContent>
            <s:NavigatorContent label="Bocadillos">
                <components:FULLTESTCOMP acItems="{acItems}" creationComplete="{initDataGrid()}"/>
            </s:NavigatorContent>
        </mx:Accordion>
    </s:Application>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This goes along with another question that I have asked, I have a drop
Setup I have an accordion layout containing a properties panel that nests two inner
No doubt elements of this question have been asked before, but I'm having trouble
I know variants of this question have been asked before (even by me), but
I want to show pop up of question with it's options. Each question have
Question: I have to create a tablet application. In this i want to make
i have a simple question: i have this var: $v = 24000,1500,1500,1500,1500,1500,; i would
I have question. I have some app on facebook and getting this error Fatal
In Programming Pearls I have met the following problem. The question is this: print
I'm trying to learn objective-c, and have a question regarding this method: - (UITableViewCell

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.