+ Start a Discussion
Shwetal DesaiShwetal Desai 

Flex Application DataGrid

Hi All,

I m trying to create a mx:DataGrid in Flex application in which i need to add columns dynamically from Query Result .
What i exactly want to do is...
I need to execute a SOQL Query [Select EmployeeID__c, EmployeeID__r.Employee__c from TimeCard__c where CheckOut__c = null and WorkType__c='Work' and DateTime__c = DateTime.now()].
now i need to add columns in Datagrid dynamically where

Number of Columns = Number of Records returned by this query;

and

Column[i]. Name = QueryResult.records[i].Value.tostring();

how can i make it possible?

Please guide
Thanks in Advance.
DevAngelDevAngel
Hi Shwetal,

Well, you will need to process the query result in action script and create the columns for your grid.  It seems like you are trying to produce some kind of "sparse grid".  Should be ok, but you won't be able to use data binding techniques (AFIK).

You will need to create an array of mx:Columns based on your query results, then add those to your mx:Grid.

myGrid.columns = genColsFromQuery(qr.records);

Or, something similiar.


Cheers
Shwetal DesaiShwetal Desai
Thanks Dave for the reply

According to ur reply i m able to add columns dynamically based on my SOQL query result.
But after doing some programming now m facing one more problem in control of Flex.
In my case i have to add columns dynamically as well as need to add rows also dynamically....
but as far as i know about i am not able to add rows dynamically by creating ArrayCollection because here I have column's dataField softcoded and number of columns also softcoded.......

any help / guidance would be a precious gift for me..


Thanks again.....

Shwetal