我正在使用Adobe Air從SalesForce獲取數據,並將其呈現在數據網格中。Adobe Flex Salesforce問題將帳戶ID轉換爲帳戶名稱
我正在使用查詢來獲取數據,然後將其放入綁定到數據網格的數組集合中,這會正常工作並顯示數據。
問題是我想要將事件中的帳戶ID轉換爲顯示帳戶名稱。要做到這一點,我用下面的代碼: -
_serviceWrapper.query("Select * From Event order by StartDateTime asc", new mx.rpc.Responder(eventQueryHandler, faultHandler))}
protected function eventQueryHandler(qr:ArrayCollection):void {
var acctIdss:String = "";
for each(var contact:DynamicEntity in qr) {
if (contact.AccountId != null && acctIdss.indexOf(contact.AccountId) == -1) {
acctIdss += "'" + contact.AccountId + "',";
}
//contact.AccountName = ""; // Add field to contact for account name
TempGridProvider.addItem(contact); // Add contact to temp grid data data provider
//TempGridProvider.contact.AccountName = "";
}
acctIdss = acctIdss.substr(0, acctIdss.length - 1);
// Query for the accounts based on the account ids found in the contact list
_serviceWrapper.query("Select Id, Name, BillingCity From Account Where Id in (" + acctIdss + ")",
new SfdcAsyncResponder(Event2QueryHandler, faultHandler));
}
protected function Event2QueryHandler(accounts:ArrayCollection):void {
for each (var account:DynamicEntity in accounts) {
for each(var contact:DynamicEntity in TempGridProvider) {
if (contact.AccountId == account.Id) {
contact.AccountName = account.Name + " - " + account.BillingCity;
}
}
}
onQueryResult(TempGridProvider);
private function onQueryResult(rows : ArrayCollection) : void {
// release previous query results
_serviceWrapper.releaseQueryResults(_gridDataProvider);
// populate datagrid
_gridDataProvider = rows;
// show message in status bar
var status : F3Message = new F3Message(F3Message.STATUS_INFO, "Query came back with " + (_gridDataProvider == null ? 0 : _gridDataProvider.length) + " " + _selectedEntity + "s");
showStatus(status);
TempGridProvider = new ArrayCollection();;
}
這工作,並顯示帳戶名,問題是,當我使用這個腳本,然後同步更改到Salesforce所有已顯示的記錄標識因爲即使只顯示它們也需要同步。
如果我跳過函數eventQueryHandler,並將我的查詢鏈接到OnQueryResult函數,那麼沒有問題,但只能顯示帳戶ID。
如何停止空氣標記這些記錄已更改,或者有更好的方法來實現這一點?
在此先感謝,任何幫助,非常感謝。
Roy
所以你想有一個DataGrid顯示來自不同數組中不同對象的字段? – 2010-11-23 15:44:24