the file names are:
"MultiGrid.mxml" and "MultiGrid.as"
not
"MutiGrid.mxml" and "MutiGrid.as"
On 12/17/05, Clint Modien <[EMAIL PROTECTED]> wrote:
Did this the other day... here's some code... with a warning though. The performance is horrible on my 1.7 GHz Pentium M laptop running the 7.x debug player. It takes about 6 seconds to load what I would call a "very" small subset of data (45KB). Maybe someone from MM can have a look at it and see if it can be optimized. Most of what I did was inspired by the grid that Steven Webster had on his blog here:
http://www.richinternetapps.com/archives/000101.html
I'm in the process of converting it to a Flex 2.0 app. *i hope it runs faster there* I'll post that too once I'm finished.
Here's the example...
---------------- App.mxml -------------------
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx=" http://www.macromedia.com/2003/mxml"
creationComplete="this_creationComplete()" themeColor="haloBlue"
backgroundColor="#707070" xmlns="*" >
<mx:Panel title="Panel1" label="Panel1" height="100%" width="100%" >
<mx:Button id="loadTestDataButton" label="Load" click="loadTestDataButton_click()" />
<MultiGrid height="100%" width="100%" dataProvider="{ ModelLocator.rootObj}" />
</mx:Panel>
<mx:HTTPService id="testService" showBusyCursor="true" useProxy="false"
url="" resultFormat="object"
result="ModelLocator.rootObj = event.result.root;" />
<mx:Script source="App.as " />
</mx:Application>
---------------- MutiGrid.mxml -------------------
<?xml version="1.0" encoding="utf-8"?>
<mx:HDividedBox xmlns:mx=" http://www.macromedia.com/2003/mxml" marginTop="0" marginBottom="0">
<mx:VBox height="100%" width="33%" marginTop="20">
<mx:DataGrid id="leftGrid" dataProvider="{ModelLocator.data}" height="100%" width="100%"
selectedIndex="{lowerGrid.selectedIndex}" hScrollPolicy="on" vScrollPolicy="off"
vPosition="{lowerGrid.vPosition}">
<mx:columns>
<mx:Array>
<mx:DataGridColumn headerText="Name" columnName="name" />
<mx:DataGridColumn headerText="Group" columnName="group" />
</mx:Array>
</mx:columns>
</mx:DataGrid>
</mx:VBox>
<mx:Canvas height="100%" width="66%" verticalGap="-1">
<mx:DataGrid id="upperGrid" hPosition="{lowerGrid.hPosition}" textAlign="center"
hScrollPolicy="on" height="40" width="100%" vScrollPolicy="on" />
<mx:DataGrid id="lowerGrid" dataProvider="{ModelLocator.data}" height="100%" width="100%"
vScrollPolicy="on" hScrollPolicy="on" y="19" selectedIndex="{ leftGrid.selectedIndex}" />
</mx:Canvas>
<mx:Script source="MultiGrid.as"/>
</mx:HDividedBox>
---------------- MutiGrid.as -------------------
import mx.controls.gridclasses.DataGridColumn;
public function set dataProvider(val:Object)
{
//make sure we're getting array's
var data = mx.utils.ArrayUtil.toArray(val.GridDataSet.GridData );
var columns = mx.utils.ArrayUtil.toArray(val.Columns.Column);
//format the grids first
renderColumns(columns);
//then bind the child props to the ModelLocator
ModelLocator.data = ""> }
private function renderColumns(columns:Array)
{
upperGrid.removeAllColumns();
lowerGrid.removeAllColumns();
var columnNumber = 0;
for (var i = 0; i < columns.length; i++)
{
// add columns to the uppergrid
var columnWidth = 100;
var column = columns[i];
var subColumns:Array = mx.utils.ArrayUtil.toArray (column.SubColumn);
var dc = new DataGridColumn();
dc.headerText = column.ColumnName;
dc.width = subColumns.length * columnWidth;
dc.colNum = i;
upperGrid.addColumn(dc);
// add columns to the lower grid
for (var j = 0; j < subColumns.length; j++)
{
var subColumn = subColumns[j];
if(subColumn == undefined) subColumn = "";
var dc2 = new DataGridColumn();
dc2.colNum = columnNumber;
columnNumber++;
dc2.headerText = subColumn;
// dc.setStyle("textAlign", "center");
dc2.columnName = "Column_"+column.ColumnID+"_"+subColumn;
dc2.width = columnWidth;
lowerGrid.addColumn(dc2);
}
}
}
---------------- ModelLocator.as -------------------
class ModelLocator
{
public static var rootObj;
public static var data:Array;
}On 12/16/05, yaagcur < [EMAIL PROTECTED]> wrote:Couple of points
a) It seems to me that if I textAlign="right" a DataGridColumn then
the column header automatically follows that designation even if I
want it to be textAlign="center" and have entered it so in DataGrid
b) How can I have two rows of headers so that the lower row can be a
subdivision of higher one
e.g
Goals Scored
Home Away
16 8
.. ..
------------------------ Yahoo! Groups Sponsor --------------------~-->
Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life.
http://us.click.yahoo.com/KIlPFB/vlQLAA/TtwFAA/nhFolB/TM
--------------------------------------------------------------------~->
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
YAHOO! GROUPS LINKS
- Visit your group "flexcoders" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.

