macromedia flash flash remoting:
Got 2 questions here. 1. How do I insert button inside data grid? 2. How do I reference the button (inside data grid) with hyperlink so that whenever users click on it, an URL is opened. Sample ouput of Data Grid. Code Category A1 Notebook <button> --> hyperlink as "http:/localhost/GetDet?id=A1" A2 PC <button> --> hyperlink as "http:/localhost/GetDet?id=A2" A3 Projector <button> --> hyperlink as "http:/localhost/GetDet?id=A3"
you must create a button cell renderer for data grid. here is how : create a folder named example , you will place your AS FILE THERE Create an empty movei name it ButtonCellRenderer on library right-click that movie choose linkage: ID: ButtonCellrenderer AS 2.0: example.ButtonCellRenderer Drag a dataGrid component name it gridDatos. Drag a Button Component to the stage then delete it (it will remain on your library); put this code on first frame of flash (or wherever you need it) arrayMio = [{field1:"Muestra",field2:"AlgunaCosa",checked:true,enabled:false}, {field1:"Muestra",field2:"AlgunaCosa",checked:false,enabled:true}, {field1:"Muestra",field2:"AlgunaCosa",checked:true,enabled:false}] import mx.controls.gridclasses.DataGridColumn var column = new DataGridColumn("field1"); column.headerText = "Campo1"; column.width = 120; gridDatos.addColumn(column); var column = new DataGridColumn("field2"); column.headerText = "Campo2"; column.width = 120; gridDatos.addColumn(column); var column = new DataGridColumn("botones"); column.headerText = "Boton"; column.width = 50; column.cellRenderer = "ButtonCellRenderer"; gridDatos.addColumn(column); //Carga los datos gridDatos.dataProvider = arrayMio; then create de AS. FILE WITH THIS. import mx.core.UIComponent import mx.controls.Button class componentes.ButtonCellRenderer extends UIComponent { var Button : MovieClip; var listOwner : MovieClip; // the reference we receive to the list var getCellIndex : Function; // the function we receive from the list var getDataLabel : Function; // the function we receive from the list function ButtonCellRenderer() { } function createChildren(Void) : Void { Button1 = createObject("Button", "Button1", 1, {styleName:this, owner:this}); Button1.addEventListener("click", this); size(); } // note that setSize is implemented by UIComponent and calls size(), after setting // __width and __height function size(Void) : Void { Button1.setSize(20, __height); Button1._x = (__width-20)/2; Button1._y = (__height-16)/2; } function setValue(str:String, item:Object, sel:Boolean) : Void { Button1._visible = (item!=undefined); Button1.selected = item[getDataLabel()]; } function getPreferredHeight(Void) : Number { return 16; } function getPreferredWidth(Void) : Number { return 20; } function click() { listOwner.dataProvider.editField(getCellIndex().itemIndex, getDataLabel(),Button1.selected); } } About desicion on each button or wich tutton to display you can create a movie clip with three labels and three diferent button and linkage it. Hope this will help you Adrian CAdena
Don't see what you're looking for? Try a search.
|