Dear All,
I have problem with that. I am attaching the code details what happend?
I will give the details i want?
In main page i have two grids and one panel with 4 to 6 text boxes.
The first grid have data with customer data (retrieving from php), while
the page loading, when i am clicking any coloum, data retrieve from php and
shows there in another gird and text boxes with address details(upto here
its working perfectly). After that i am clicking the second grid contains
data, i want the datas retrieves from php and sql server and showing in
another gird in popup window.
Please help me out.
Thanks
Kurakar
On Thursday, October 22, 2009 2:08:16 PM UTC+4, mman wrote:
>
> Hi everybody,
> the goal os to open a new window after clicking a button in my Flex
> Application. Openning the window is not a problem, however, what I
> could not do is:
> - sending an ArrayCollection object to the window
> - receiving this ArrayCollection in the new window
>
> I want to use this ArraCollection as adata provider for an
> AdvancedDataGrid that the new window should show.
>
> I need an urgent help!
>
--
You received this message because you are subscribed to the Google Groups "Flex
India Community" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/flex_india/-/66WTmFrqEwkJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/flex_india?hl=en.
<?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"
xmlns:sqlget="services.sqlget.*"
width="100%" height="100%" minWidth="2000"
minHeight="1000" backgroundColor="#5F2121"
initialize="getData()">
<fx:Declarations>
<mx:HTTPService id="update_data" method="POST"
url="http://localhost:8080/sql/updte.php" useProxy="false"
result="resultHandler(event)">
<mx:request xmlns="">
<fax>{faxTxt.text}</fax>
<telephone>{teleTxt.text}</telephone>
<context>{cntTxt.text}</context>
<address1>{addr1Txt.text}</address1>
<address>{addrTxt.text}</address>
<email>{emailTxt.text}</email>
<mobile>{mobTxt.text}</mobile>
</mx:request>
</mx:HTTPService>
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.events.ListEvent;
import mx.formatters.DateFormatter;
import mx.managers.PopUpManager;
import mx.rpc.events.ResultEvent;
import mx.rpc.http.mxml.HTTPService;
[Bindable]
private var customersData:ArrayCollection;
[Bindable]
private var resultSearch:ArrayCollection;
[Bindable]
private var notes:ArrayCollection;
[Bindable]
private var addressDetails:Object;
private var customerServiceUrl:String =
"http://localhost:8080/sql/index.php"
private var customerSearchServiceUrl:String =
"http://localhost:8080/sql/search.php"
private var invoicedata:String =
"http://localhost:8080/sql/invoice.php"
private var customerAdressSearchServiceUrl:String =
"http://localhost:8080/sql/address.php"
private var _dateformatter:DateFormatter = new
DateFormatter();
private var newPopUp:MyFirstPopup;
private function showPopUp(event:ListEvent):void
{
if(resultSearch == null || event.rowIndex<0 ||
event.rowIndex >=resultSearch.length)
{
return;
}
var customer:Object =
resultSearch.getItemAt(event.rowIndex);
var newPopUp:MyFirstPopup =
MyFirstPopup(PopUpManager.createPopUp(this, MyFirstPopup, true));
var invoice:String =customer.email1;
var jv:String = customer.testid1;
var value:String = compid.text;
var inv:ArrayCollection = notes;
newPopUp.phoneNumber = invoice;
newPopUp.compid = value;
newPopUp.jvType = jv;
newPopUp.invdetails=notes;
PopUpManager.centerPopUp(newPopUp);
}
// ...............................popup
details..............................//
public function getselectedinvoice(event:ListEvent):void
{
var invoice:Object =
resultSearch.getItemAt(event.rowIndex);
getdetails(invoice);
}
public function getdetails(invoice:Object):void
{
var service:HTTPService = new HTTPService();
service.url=invoicedata;
service.method = "POST";
service.addEventListener(ResultEvent.RESULT,getinv);
var param_value_1:String = invoice.account1;
var parameters:Object = new Object;
parameters["keyword"] = param_value_1;
service.send(parameters);
}
public function getinv(event:ResultEvent):void
{
if(event.result == null || event.result.people1
== null || event.result.people1.person1 == null)
{
return;
}
notes = event.result.people1.person1 as
ArrayCollection;
notes.refresh();
}
//................finish popup
details...........................................//
private function
formatDate(item:Object,column:DataGridColumn):String
{
_dateformatter.formatString = "DD/MM/YYYY";
return
_dateformatter.format(item[column.dataField]);
}
//----------------------------------------------------------//
public function getData():void
{
var _service:HTTPService = new HTTPService();
_service.url = customerServiceUrl;
_service.useProxy=false;
_service.addEventListener(ResultEvent.RESULT,
getCustomersData);
_service.send();
}
public function getCustomersData(event:ResultEvent):void
{
customersData = event.result.people.person as
ArrayCollection;
customersData.filterFunction =
filterDataCustomers;
}
protected function fnSearchGrid():void
{
emaillist.dataProvider.filterFunction =
filterGrid;
emaillist.dataProvider.refresh();
}
public function filterGrid(item:Object):Boolean
{
var arrColumn:Array = new Array();
arrColumn.push('testid','name','email','debit');
for(var i:int=0;i<arrColumn.length;i++)
{
var name:String =
String(item[arrColumn[i]]).toLowerCase();
var beginsWithString:String =
txtFilter.text.toLowerCase();
if(name.indexOf(beginsWithString) == 0)
{
return true;
}
}
return false;
}
public function searchChanged(event:Event):void
{
if(customersData != null){
customersData.refresh();
}
}
public function
filterDataCustomers(customer:Object):Boolean{
if(customer == null){
return false;
}
return(
(String(customer.testid).toUpperCase().indexOf(txtFilter.text.toUpperCase())
>=0)
||
(String(customer.name).toUpperCase().indexOf(txtFilter.text.toUpperCase()) >=0)
||
(String(customer.email).toUpperCase().indexOf(txtFilter.text.toUpperCase()) >=0)
||
(String(customer.debit).toUpperCase().indexOf(txtFilter.text.toUpperCase()) >=0)
);
}
//................................................................................//
public function getSelectedRowData(event:ListEvent):void
{
var customer:Object =
customersData.getItemAt(event.rowIndex);
getCustomerSearchData(customer);
getAddressData(customer);
compid.text = event.itemRenderer.data.testid;
}
public function
getCustomerSearchData(customer:Object):void
{
var service:HTTPService = new HTTPService();
service.url=customerSearchServiceUrl;
service.method = "POST";
service.addEventListener(ResultEvent.RESULT,getSearchResult);
var param_value_1:String = customer.testid;
var parameters:Object = new Object;
parameters["keyword"] = param_value_1;
service.send(parameters);
}
public function getSearchResult(event:ResultEvent):void
{
if(event.result == null || event.result.people1
== null || event.result.people1.person1 == null)
{
return;
}
resultSearch = event.result.people1.person1 as
ArrayCollection;
resultSearch.refresh();
}
//-----------------------------------address
details----------------------------------//
public function getAddressData(customer:Object):void
{
var service:HTTPService = new HTTPService();
service.url=customerAdressSearchServiceUrl;
service.method = "POST";
service.addEventListener(ResultEvent.RESULT,getaddressDetails);
var param_value_1:String = customer.testid;
var parameters:Object = new Object;
parameters["keyword"] = param_value_1;
service.send(parameters);
}
public function
getaddressDetails(event:ResultEvent):void
{
if(event.result == null || event.result.people2
== null || event.result.people2.person2 == null)
{
return;
}
addressDetails = event.result.people2.person2
as Object;
if(compid.text)
{
// you can test that :) :) ok
faxTxt.text = addressDetails.email2;
teleTxt.text = addressDetails.name2;
cntTxt.text = addressDetails.debit2;
addr1Txt.text = addressDetails.testid2;
addrTxt.text = addressDetails.account2;
emailTxt.text = addressDetails.credit2;
mobTxt.text = addressDetails.mob;
}
else
{
addressDetails.email2= "";
addressDetails.name2 = "";
addressDetails.debit2 = "";
addressDetails.testid2 = "";
addressDetails.account2 = "";
addressDetails.credit2 = "";
addressDetails.mob = "";
}
//addressDetails.refresh();
}
//.........................update....................................//
public function resultHandler( event: ResultEvent ):void
{
Alert.show(compid.text+ " Updated");
}
public function sendData():void
{
var objSend:Object = new Object;
objSend.first = compid.text;
objSend.second = faxTxt.text;
objSend.third = teleTxt.text;
objSend.fourth = addr1Txt.text;
objSend.fivth = addrTxt.text;
objSend.sixth = emailTxt.text;
objSend.seventh = mobTxt.text;
objSend.eigth = cntTxt.text;
update_data.send( objSend );
}
]]>
</fx:Script>
<mx:TextInput x="121" y="58" id="txtFilter" width="440" height="27"
fontSize="20" fontWeight="bold" change="fnSearchGrid()"/>
<mx:DataGrid id="emaillist" x="10" y="90" width="553" height="501"
itemClick="getSelectedRowData(event)"
dataProvider="{customersData}">
<mx:columns>
<mx:DataGridColumn width="100" dataField="testid"
headerText="Customer ID"/>
<mx:DataGridColumn width="250" dataField="name"
headerText="Customer Name"/>
<mx:DataGridColumn width="100" dataField="email"
headerText="Open Balance"/>
<mx:DataGridColumn width="100" dataField="debit"
headerText="Balance"/>
</mx:columns>
</mx:DataGrid>
<mx:DataGrid id="statement" x="580" y="277" height="313"
dataProvider="{resultSearch}" doubleClickEnabled="true"
itemDoubleClick="showPopUp(event)">
<mx:columns>
<mx:DataGridColumn width="100" dataField="account1"
headerText="Account No."/>
<mx:DataGridColumn width="100" dataField="email1"
headerText="Invoice No."/>
<mx:DataGridColumn width="100" dataField="testid1"
headerText="JV Type"/>
<mx:DataGridColumn width="150" dataField="name1"
headerText="JV Date" labelFunction="formatDate" />
<mx:DataGridColumn width="100" dataField="debit1"
headerText="Type"/>
<mx:DataGridColumn width="100" dataField="credit1"
headerText="Amount"/>
</mx:columns>
</mx:DataGrid>
<s:Label x="44" y="65" text="SEARCH" fontSize="16" color="#ffffff"
fontWeight="bold"/>
<s:Panel x="580" y="59" width="649" height="200" title="Address
Details" >
<s:Label x="14" y="16" text="Address Details"/>
<s:Label x="12" y="82" text="Telephone"/>
<s:Label x="346" y="79" text="Fax"/>
<s:Label x="346" y="117" text="Mob. No."/>
<s:Label x="10" y="115" text="Contact Person"/>
<s:Label x="346" y="45" text="Email"/>
<s:TextInput id="teleTxt" x="106" y="74" width="222"
enabled="{editCheck.selected}"/>
<s:TextInput id="mobTxt" x="403" y="107" width="234"
enabled="{editCheck.selected}"/>
<s:TextInput id="faxTxt" x="401" y="71" width="236"
enabled="{editCheck.selected}"/>
<s:TextInput id="addrTxt" x="108" y="10" width="529"
enabled="{editCheck.selected}"/>
<s:TextInput id="addr1Txt" x="107" y="40" width="223"
enabled="{editCheck.selected}"/>
<s:TextInput id="emailTxt" x="401" y="38" width="236"
enabled="{editCheck.selected}"/>
<s:TextInput id="cntTxt" x="105" y="109" width="228"
enabled="{editCheck.selected}"/>
<s:CheckBox id="editCheck" x="545" y="-23" label="Enable Edit"/>
<s:TextInput id="compid" x="120" y="-28" enabled="false"/>
</s:Panel>
<s:Button id="saveBtn" x="1242" y="63" width="85" height="46"
label="Save" click="sendData()"/>
</s:Application><?xml version="1.0" encoding="utf-8"?>
<s:TitleWindow xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
close="titlewindow1_closeHandler(event)"
width="706" height="300" title="Show datas">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects)
here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.events.CloseEvent;
import mx.events.FlexEvent;
import mx.events.ListEvent;
import mx.formatters.DateFormatter;
import mx.managers.PopUpManager;
import mx.rpc.events.ResultEvent;
import mx.rpc.http.mxml.HTTPService;
[Bindable]
public var phoneNumber:String;
[Bindable]
public var compid:String;
[Bindable]
public var jvType:String;
[Bindable]
public var invdetails:ArrayCollection;
protected function
titlewindow1_closeHandler(event:CloseEvent):void
{
PopUpManager.removePopUp(this);
}
]]>
</fx:Script>
<s:TextInput id="PhoneNumberTxt" x="82" y="4" text="{phoneNumber}"/>
<s:Label x="10" y="9" text="Invoice No :"/>
<s:TextInput id="compidTxt" x="308" y="4" text="{compid}"/>
<s:TextInput id="jvTypeTxt" x="563" y="4" text="{jvType}"/>
<s:Label x="230" y="10" text="Company Id:"/>
<s:Label x="481" y="10" text="JV TYPE:"/>
<mx:DataGrid id="emaillist1" x="11" y="38" width="683"
dataProvider="{invdetails}" >
<mx:columns>
<mx:DataGridColumn width="100" dataField="account2"
headerText="Customer ID"/>
<mx:DataGridColumn width="250" dataField="testid2"
headerText="Customer Name"/>
<mx:DataGridColumn width="100" dataField="mob"
headerText="Open Balance"/>
<mx:DataGridColumn width="100" dataField="name2"
headerText="Balance"/>
</mx:columns>
</mx:DataGrid>
</s:TitleWindow>
<?php
$keyword = $_POST['keyword'];
//$connection_string = 'DRIVER={SQL
Server};SERVER=TSERVER\SQLEXPRESS;DATABASE=COMRADEERP6';
$connection_string = 'DRIVER={SQL
Server};SERVER=qamar-dubai.dyndns.org,1475\SQLEXPRESS;DATABASE=COMRADEERP6';
$connection = odbc_connect($connection_string, "sa", "QDCqdc123");
$select = "SELECT * FROM asadr where account LIKE '%$keyword%'";
$result = odbc_exec($connection, $select);
print "<people2>\n";
while(odbc_fetch_row($result))
{
$add1=odbc_result($result,"address1");
$add2=odbc_result($result,"address2");
$mob=odbc_result($result,"address3");
$phone=odbc_result($result,"phone");
print
"<person2><account2>".$add1."</account2><testid2>".$add2."</testid2><mob>".$mob."</mob><name2>".$phone."</name2></person2>\n";
}
print "</people2>";
?>