Hi

I have a huge problem.

I am making a type of a ganttChart and im trying to do it like this.

I get an Array from server containind calendar data.
then i get a array from server containing info about projects.

then I create an Advanced datagrid and compare the two arrays and if there
is a mach in day.id and project .id I want to ad an UIComponent in that
cell.

is this possible?

here is the function for creating the grid

& the itemRenderClass

private function createGrid():void{
            gridArray = modelLocator.currentArray;

            var projectGroup:Array = new Array();
            var weekGroups:Array = new Array();
            var weekGroup:TrafficGridColumnGroup;

            var projectsGroup:TrafficGridColumnGroup
            var projectColumn:TrafficGridColumn;

            projectsGroup = new TrafficGridColumnGroup();
            projectsGroup.editable = true;
            projectsGroup.headerText = ("Username: ");
            projectsGroup.minWidth = 140;

            projectColumn = new TrafficGridColumn();
            projectColumn.headerText = "Projects";
            projectColumn.dataField = "name";
            projectColumn.width = 140;
            projectColumn.editable = true;

            projectsGroup.children.push(projectColumn);
            weekGroups.push(projectsGroup);

            for each (var week:Array in gridArray){
                weekGroup = new TrafficGridColumnGroup();
                weekGroup.headerText = ("Uke: "+week[0].week);
                weekGroup.editable = true;
                weekGroup.minWidth = 50;
                weekGroup.children = [];
                weekGroups.push(weekGroup);

                for(var i:uint = 0 ; i < week.length; i+=2){

                    dayName = getShortVersionOfDayname(week[i].dayname);

                    if(dayName != "Lør" && dayName != "Søn"){

                        dayColumn = new TrafficGridColumn();
                        var
dayDescription:AdvancedDataGridRendererDescription = new
AdvancedDataGridRendererDescription();
                        dayDescription.rowSpan = 1;

                        dayColumn.editable = true;
                        dayColumn.itemEditor = new ClassFactory(TextInput);
                        dayColumn.headerText = dayName;
                        dayColumn.minWidth = 35;
                        dayColumn.id = week[i].id;
                        //dayColumn.labelFunction = displayPersonInfo ;
                        dayColumn.itemRenderer = new
ClassFactory(ProjectRender);
                        dayColumn.styleFunction = myStyleFunction;
                        dayColumn.labelFunction = dayColumn.setLabel;

                        weekGroup.children.push(dayColumn);
                    }
                }
            }
             trafficGrid.groupedColumns  = weekGroups;
        }




----------------------------------------------------------------------------

package traffic.view.main.time.renderer
{
    import mx.controls.AdvancedDataGrid;
    import mx.controls.Label;
    import mx.controls.advancedDataGridClasses.AdvancedDataGridListData;
    import mx.core.UIComponent;

    import traffic.model.ViewModelLocator;

     [Style(name="backgroundColor", type="uint", format="Color",
inherit="no")]
    public class ProjectRender extends Label {
        private var modelLocator:ViewModelLocator =
ViewModelLocator.getInstance();
        private var grid1:AdvancedDataGrid;

        public var bgComp:UIComponent;

        public function ProjectRender() {
            super();
            this.bgComp = new UIComponent();

        }

        override protected function updateDisplayList(unscaledWidth:Number,
unscaledHeight:Number):void    {
            super.updateDisplayList(unscaledWidth, unscaledHeight);
            grid1 =
AdvancedDataGrid(AdvancedDataGridListData(listData).owner);
         }

        override protected function createChildren():void{
            super.createChildren();
            bgComp.graphics.beginFill(0x0000FF, .1);
            bgComp.graphics.drawRect(0, 0, 40, 5);
            bgComp.graphics.endFill();
            bgComp.visible = true;
            addChild(bgComp);
        }

        public function setObjVisible(visible:Boolean):Boolean {
            return visible;
        }
    }
}

Reply via email to