Skip to main content
March 1, 2012
Answered

Add Slider to Datagrid?

  • March 1, 2012
  • 1 reply
  • 649 views

Is it possible to add a slider to a datagrid. Basically, a column of sliders.

This topic has been closed for replies.
Correct answer kglad

i'd use a movieclip with a slider component and assign it a class that extends MovieClip and implement ICellRenderer.

1 reply

kglad
Community Expert
Community Expert
March 1, 2012

yes.  you'll need to create a custom cellrenderer.  google a tutorial to get started:

"flash as3 datagrid custom cellrenderer tutorial"

March 1, 2012

Thanks for your help. I got the slider in the dg. But I cant find out how to move it down a little. for now its stuck at the top. Any suggestions?

How I assign the cell to DG

col3 = dg.getColumnAt(3);

col3.cellRenderer = LoaderCellRenderer;

LoaderCellRenderer

package ControlPanel.CommonFiles.Util

{

          import fl.controls.Slider;

          import flash.events.Event;

          import fl.data.DataProvider;

          import fl.controls.listClasses.ListData;

          import fl.controls.listClasses.ICellRenderer;

          public class LoaderCellRenderer extends Slider implements ICellRenderer

          {

                    protected var _data:Object;

                    protected var _listData:ListData;

                    protected var _selected:Boolean;

                    private var _selecteditem:Object;

                    private var _sliderValue:Number;

                    public static var _stage;

                    public function LoaderCellRenderer()

                    {

                              super();

                              addEventListener(Event.CHANGE, onSelItem);

                    }

                    public function onSelItem(evt:Event):void

                    {

                              _value = evt.target.value;

 

                    }

                    public function get data():Object

                    {

                              return _data;

                    }

                    public function set data(value:Object):void

                    {

                              _data = value;

                    }

                    public function get listData():ListData

                    {

                              return _listData;

                    }

                    public function set listData(value:ListData):void

                    {

                              _listData = value;

                    }

                    public function get selected():Boolean

                    {

                              return _selected;

                    }

                    public function set selected(value:Boolean):void

                    {

                              _selected = value;

                    }

                    public function setMouseState(state:String):void

                    {

                    }

          }

}

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
March 1, 2012

i'd use a movieclip with a slider component and assign it a class that extends MovieClip and implement ICellRenderer.