View Full Version : How to decide what order of columns in datagrid? SQL
Tackle
12-24-2008, 09:07 PM
I'm getting an SQL result into my datagrid.
Is there any way to dictate the order they appear in? The columns, that is.
Or any other way to get more control of it in general?
I also would like to be able to somehow combine 2 different sql data sources into one single datagrid. Is that possible?
For example:
SQL result 1 gives two columns:
ID, Name
Result 2 gives another two:
ID, Boolean
My goal is to have a datagrid with:
ID, Name, Boolean
Where the ID is the same, basically.
My guess is this would rather be sorted at SQL query level, but I'm not sure?
Tackle
12-24-2008, 09:35 PM
I should add that I've found a way to do this the mxml way:
<mx:DataGrid id="resultsGrid" height="100%" width="100%">
<mx:columns>
<mx:DataGridColumn headerText="#" dataField="id" width="20"/>
<mx:DataGridColumn headerText="Item" dataField="item"/>
<mx:DataGridColumn headerText="The price" dataField="price"/>
</mx:columns>
</mx:DataGrid>
Where the dataField equals the column name coming in from the SQL result.
But the issue is that my columns will be generated depending on the amount of users in a database, so it has to be done in pure actionscript somehow.
How do I put, for example, this line:
<mx:DataGridColumn headerText="#" dataField="id" width="20"/>
into actionscript?
-- EDIT
The "-keep-generated-actionscript" compiler argument solved this for me, of course.
For example:
columns: [_LokalDatabasTest_DataGridColumn1_c(), _LokalDatabasTest_DataGridColumn2_c()]
private function _LokalDatabasTest_DataGridColumn1_c() : mx.controls.dataGridClasses.DataGridColumn
{
var temp : mx.controls.dataGridClasses.DataGridColumn = new mx.controls.dataGridClasses.DataGridColumn();
temp.headerText = "#";
temp.dataField = "id";
temp.width = 20;
return temp;
}
private function _LokalDatabasTest_DataGridColumn2_c() : mx.controls.dataGridClasses.DataGridColumn
{
var temp : mx.controls.dataGridClasses.DataGridColumn = new mx.controls.dataGridClasses.DataGridColumn();
temp.headerText = "Item";
temp.dataField = "item";
return temp;
}
Where columns is a property of the DataGrid, of course
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.