问题:我有一个带有 3 个索引的手风琴,每个索引包含一个组件。该组件始终是相同的(一个普通的数据网格)。这个数据网格通过 php 和 JSON 接收他的数据。
现在,当我的手风琴的 SelectedIndex 发生变化时,我的数据网格中的数据应该会发生变化。
这是 php 查询:
$query = "SELECT * FROM gerecht where typeID = " . $typeId;
$typeId
selectedIndex在哪里
if(isset($_POST['accIndex'])){
$typeId = mysql_real_escape_string($_POST['accIndex']);
} else {
$typeId = 1;
}
现在,每当我更改手风琴索引时,数据都保持不变。这是我的弹性代码:
<?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>
我猜在以下方面出了点问题: - php 接收到 selectedIndex?- 或者 flex 不能用新数据更新数据网格?