AdavancedDataGrid dynamic itemRenderer
I need to change the properties of a button used as an
itemrenderer in AdvancedDataGrid - previously I used a method for
DataGrid that worked nicely but I cannot seem to get my modified
code to work with ADG.
Seems to center around being able to identify the listData
for the IR. It keeps coming up null. Utlimately I need to get
listData.owner in order to get the isSelectedItem(data) property
for the IR. Any ideas ???
"flexstone" <[email protected]> wrote in
message
news:gkpsq4$b4o$[email protected]..
>I need to change the properties of a button used as an
itemrenderer in
> AdvancedDataGrid - previously I used a method for
DataGrid that worked
> nicely
> but I cannot seem to get my modified code to work with
ADG.
>
> Seems to center around being able to identify the
listData for the IR. It
> keeps coming up null. Utlimately I need to get
listData.owner in order to
> get
> the isSelectedItem(data) property for the IR. Any ideas
Why not just use a styleFunction?
HTH;
Amy
Similar Messages
-
Dynamic setting of itemRenderer in datagrid
Can we dynamically set the itemrenderer in a datagrid
depending upon some value in data?HI,
how about to display different controls in a rows for that column? Can it be done?
Thanks,,
-jenue -
Datagrid itemRenderer dynamic values
While working on an application I came across the following
problem. I've got a view with a datagrid, where I have several
columns. Each column needs 2 values displayed beneath each other in
one cell. You make an itemRenderer with 2 labels inside a VBox.
Easy so far. However since this scenario repeats several times it
seems counterproductive to make an itemRenderer for each cell. How
can I make the text property for the labels change for each cell
instead of being static in their values.
Thx in advance.Your description of your requirements and your sample code do
not paint a clear enough picture.
Your dataProvider has 4 pieces of data: batchId,
bookingNumber, valueDate, immsBranch. Your current itemRenderer
references two of those pieces of data, and you say you want to
reference the other two. You can do that easily like this:
<mx:Label text="data.valueDate"/>
<mx:Label text="data.immsBranch"/>
A basic question: will your DataGrid have two rows for each
set of 4 pieces of data? If so then I understand your problem. If
not, then you must clarify exactly how and when you would like the
4 pieces of data shown in your DataGrid.
In any case, you probably need a Repeater, and then need to
figure out how to get at the right data at the right time in the
Repeater.
See this FB 3 help topic and its sub-topics:
Dynamically Repeating Controls and Containers
Also search for this in the FB3 help to see the API:
mx.core.Repeater
You can define a listener for the Repeater for the Repeat
event to specify processing for each iteration of the
repeater. -
Hi,
I'm creating a thumb photo gallery and I'm using a tilelist
component as the Gallery container as the itemrender I'm using a
mxml component created by me, so I need to change this itemrenderer
to other mxml component in runtime, i could be by a combobox, I
don't no how change it dynamic, in the script, if somebody can help
me, I'll be so thankful...Yes, you can, but you need to use a "classFactory". I've not
done this myself, but have seen examples. I think you will find
examples via google.
Tracy -
Dynamically set itemRenderer content width
Hey all,
thanks for taking time to look at this. what I'm trying to do
is simple, I think, but evading me. I've got a datagrid set to 100%
width. I've got a total of 7 columns, the first 2 are fixed width.
The remaining 5 columns (and their contents, importantly), should
dynamically size to take up the remaining area. I'm using
comboboxes within these columns, and can't seem to set the width of
these comboboxes based on the width of the column they appear
within. I've tried just setting them to 100%, but that causes a
scrolltrack to appear and the combobox is hidden behind the
scrolltrack.
help is greatly appreciatedAre you using a drop in, inline, or custom component for an
itemRenderer? I do not think you can do this with a drop in item
renderer. I think you can do it using an inline itemRenderer but
this is not an ideal solution. I think that if you use a custom
component as the item renderer you could use databinding on the
width of the combo box where the data grid column of the data used
is the source.
ie. comboBox width="{columnx.width}" where columnx
corresponds to the column housing the combobox. -
Dynamically resizing itemrenderer
Hi,
Can anyone give me a few hints or point me to some sample code that will dynamically (and ideally, smoothly) resize a custom itemrenderer in a tileList component?
I currently have a tileList with a custom itemRenderer that extends vbox. It is a very simple component consisting of a Image and a label below it. Elsewhere in my app I have a Hslider that I would like to use to set the 'zoom' on my tileList (so resizing my custom itemRenderer).
As a first step I would like the images to resize smoothly, but another wrinkle is as the images become bigger (or smaller), I will need the tileList to dynamically change the number of columns displayed.
Any hints or pointers would be appreciated.
Thanks,
CliffI have found some code to do it. It's not perfect, but it works pretty well. I followed the lead of this guy here:
http://blog.flexmonkeypatches.com/2009/01/20/poor-mans-zooming-flex-tilelist/
I did something like this:
//http://www.actionscript.org/forums/showthread.php3?t=116021
private function sliderChange(target:TileList, event:SliderEvent):void {
var currentSlider:Slider=Slider(event.currentTarget);
target.columnCount = Math.floor(target.width/currentSlider.value);
target.rowCount= Math.floor(target.height/currentSlider.value);
target.columnWidth = currentSlider.value;
target.rowHeight = currentSlider.value;
and this:
<mx:HSlider liveDragging="true"
id="dim"
value="25"
tickInterval="5"
snapInterval="5"
labels="['0', '100']"
minimum="25"
maximum="200"
change="sliderChange(mapTileList,event)"/> -
Dynamic validators and itemrenderer
Hi,
I have a bunch of dynamic validators that i create in my application.
I have a s:DataGroup which contains an itemRenderer. In this itemRenderer, I have a combobox which I want to validate.
I perform the validation like this:
protected function performValidation(event:FocusEvent):void
var condition:Condition = data as Condition;
condition.validator.listener = valuesComboBox;
condition.validator.validate(valuesComboBox.textInput.text);
Of course, when I do this, the itemrenderer is recycling, and the validator appears in comboboxes in which i do not want it to.
Anybody have any idea how i can work around this problem?
Thanks,
JamieHi,
I have a bunch of dynamic validators that i create in my application.
I have a s:DataGroup which contains an itemRenderer. In this itemRenderer, I have a combobox which I want to validate.
I perform the validation like this:
protected function performValidation(event:FocusEvent):void
var condition:Condition = data as Condition;
condition.validator.listener = valuesComboBox;
condition.validator.validate(valuesComboBox.textInput.text);
Of course, when I do this, the itemrenderer is recycling, and the validator appears in comboboxes in which i do not want it to.
Anybody have any idea how i can work around this problem?
Thanks,
Jamie -
Problem in accessing the itemRenderer dynamically
Hi,
In my application i am using two AdvanceddataGrids. i am showing one datagrid at a time based on the user selection. I have provided the buttons to switch between the grids. These two datagrids are getting the data from XML. By default the data will be available for the first datagrid in XML. Once the user selects the second grid, i am using the HTTPService to fetch the data for that particular grid. (This HTTPService will pass this grid's id as QueryString to the same XML page, and the .Net will read these parameters to fetch the required data from the DB and will print the data in the XML format in the same page).
Here, for the first datagrid, i have used the itemRenderer to show some images (in the datagrid) based on the data available in XML. And i have followed the same for the second grid also.
But the probelm is, whenever the application starts runnning (on Creation complete of the application), i am not able to view the images for the first datagrid, since the data for the second datagrid is not available (i have defined the itemRenderer for the second dataGrid based on XML data).
I have stored the itemRenderers for each datagrid as a separate component. Is there any way to add this itemRenderer component during the run time. (While the user clicks the button to view the second datagrid)?
"(Second datagrid's) coloumnid.itemRenderer = mycomponent.mxml" (I have tried this code to access during selection of second datagrid. But it didn't work).
Could someone help me on this?When you say:
But the probelm is, whenever the application starts runnning (on Creation complete of the application), i am not able to view the images for the first datagrid, since the data for the second datagrid is not available (i have defined the itemRenderer for the second dataGrid based on XML data).
I don't understand. Why would the images in the first datagrid not be availabe because the data for the second grid is not available?
If certain data needs to be loaded for creationComplete, then ensure it is loaded.
Perhaps you can clarify these points as your scenario is not clear. -
Dynamic datagrid rowHeight and itemRenderer problem
Hi guys,
Long time listener; first time caller....
I have had a look around the forums here and i can see there are a lot of similar issues to the one i'm currently having but not so many solutions. Not sure if i'll have any better luck with my question but here goes...
My issue is to do with the row height of a datagrid row not matching up properly with the height of the custom iterm renderer used on a column.
The item renderer consists of an HBox containing an image and a textArea. The image will not always be present and the text area can contain a couple of words or many lines of text.
I have overridden the measure function of the item render in which i am manually setting the HBox's height and measuredHeight.
Problem is that i have to find some way of triggering a redraw of the datagrid AFTER if have set the item renderers height, but i dont seem to be able to directly access the in-line renderer from the parent class.
If anyone could throw any suggestions my way it would be greatly appreciated!
thanks '
DaveOk so here's the sample code...
****Renderer*****
<?xml version="1.0" encoding="utf-8"?>
<mx:HBox
horizontalAlign="
left" verticalAlign="
middle" horizontalGap="
0"verticalGap="
0"xmlns:mx="
http://www.adobe.com/2006/mxml" horizontalScrollPolicy="
off"verticalScrollPolicy="
off"width="
100%" height="
100%"resize="measure()"
borderColor="
green"borderStyle="
solid"
>
<mx:Metadata>[
Event(name="gridRowHeightChange", type="flash.events.Event")]
</mx:Metadata>
<mx:Script>
<![CDATA[
import mx.events.ResizeEvent;
import flash.events.Event;
Bindable] public var showLocalPartImage:Boolean = false;
override public function set data(value:Object):void
super.data = value;
lblPartNum.text = data.label;}
override protected function measure():void
super.measure();
if(lblPartNum.text != "" && lblPartNum.width > 0) {
lblPartNum.validateNow(); lblPartNum.mx_internal::getTextField().autoSize = TextFieldAutoSize.LEFT;
lblPartNum.height =
this.height = measuredHeight = lblPartNum.mx_internal::getTextField().height;
dispatchEvent(
new Event("gridRowHeightChange")); }
]]>
</mx:Script>
<mx:Image id="imgLocal" horizontalAlign="center" verticalAlign="middle" visible="false" width="{0}"/>
<mx:TextArea id="lblPartNum" width="{this.width - imgLocal.width - 4}" height="100%" editable="false" verticalScrollPolicy="off" />
</mx:HBox>
****EndRenderer*****
****DataGrid****
public function measureGrid(event:Event):void{
shoppingCart.removeEventListener(DataGridEvent.COLUMN_STRETCH, measureGrid);
shoppingCart.invalidateList();
shoppingCart.addEventListener(DataGridEvent.COLUMN_STRETCH, measureGrid);
<mx:DataGrid id="shoppingCart"width="
100%" height="100%"dataProvider="
{_order.orderItems}"allowMultipleSelection="
true"sortableColumns="
true"variableRowHeight="
true"doubleClickEnabled="
true"doubleClick="selectPartHandler(event)"
paddingRight="
5"editable="
false"
>
<mx:columns>
<mx:DataGridColumn width="22" minWidth="20" sortable="false" editable="false"/>
<mx:DataGridColumn width="22" minWidth="20" sortable="false" editable="false"/>
<mx:DataGridColumn minWidth="240" width="270" dataTipField="description" dataField="description" headerText="Description"editable="
false" wordWrap="true">
<mx:itemRenderer>
<mx:Component>
<controls:DescriptionShoppingCartRenderer showLocalPartImage="
{!(outerDocument.displayUnderline)}" gridRowHeightChange="{outerDocument.measureGrid(event)}">
</controls:DescriptionShoppingCartRenderer>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
****EndDataGrid****
Unfortunately the whole code is much too large to fit in here, but here are the main working parts.
I hope this helps.
What i am getting when running this is strange. When i run the first time and when i resize a column, the row height is incorrect, but then when i just click the 'column stretch' arrow (ie the space between the column headers) and dont actually resize at all, the row heights re-calculate and they fit perfectly.
This makes me think that i need to trigger this event manually AFTER the itemRenderer has been calculated.
EDIT: forgot to add the measureGrid function -
Dynamic height of mx:Text in List ItemRenderer
Hello,
I want to have a list with line breaks if the width of the
items is higher then the width of the list.
I wrote my custon ItemRender but if i set the no height to
the mx:Text there would be only first line tdisplayed on the list
My List looks like this
<mx:List id="level1" dataProvider="{level1List}"
width="100%" height="100%"
change="selectLevel1ItemEvent(event)">
<mx:itemRenderer>
<mx:Component>
<mx:VBox height="100%">
<mx:Text width="100%" height="40" text="{data.desc}"/>
</mx:VBox>
</mx:Component>
</mx:itemRenderer>
</mx:List>
The problem is that know all items have a height to fit an
item with two lines. I want only have this if the width of an item
is higher than the width of the list.
Thanks,
Stefantry setting minHeight of the RTE to 0
-
Using itemRenderer in Dynamic Grid
Hi,
I have grid with takes in a ArrayCollection as dataProvider.
Also the columns of the datagrid is defined from the action script.
At the mxml level, I have only the DataGrid tag. Now my data
contains some severity levels - critical, moderate and ok. Based on
what comes in, I want an itemRenderer which will print a different
image for each severity. i.e. if the value is critial, i want a red
color icon to be shown in the cell.
I wish to do this with actionscript itself. I am stuck at the
itemRenderer part. I checked out the examples. All of them work
with mxml tags for itemRenderer using images. I want the renderer
to be through actionscript. Has anyone done this? Can anybody help
me with this?
Cheers,
UdayHi Uday,
Were you ever able to accomplish this? I'm looking to do
something almost exactly the same, where I have data that provides
one of two values, and I want to translate those values into one of
two icons.
If you were able to do this, I'd appreciate any explanatory
help. Or if someone else out there has an answer to his original
post, I'm sure it would be appreciated by more than just myself.
Thanks,
Josh -
Custom ItemRenderer with dynamic field associations?
Hi All,
I'm trying to create a custom itemrender control that isn't tied to a specific type of data input. I'm creating a thumbnail itemrenderer to be used with the Sparks List control:
<?xml version="1.0" encoding="utf-8"?>
<s:ItemRenderer
xmlns:fx="
http://ns.adobe.com/mxml/2009" xmlns:s="
library://ns.adobe.com/flex/spark" xmlns:mx="
library://ns.adobe.com/flex/mx" autoDrawBackground="
true"
>
<s:layout>
<s:BasicLayout/>
</s:layout>
<mx:Image left="
5" right="
5" bottom="
25" top="
5" id="
img_thumbnail"source="
{data.image}"
/>
<s:Label
left="
5" right="
5" bottom="
5" verticalAlign="
middle" textAlign="
center" id="
lbl_label" fontWeight="
bold" fontSize="
10"text="
{data.label}"
/></s:ItemRenderer>
However, as you can see, the image source and label text properties are tied to specific fields in the data collection (image and label). I would like to provide a way to figure out what the label and icon fields are set to in the parent control, and set them accordingly in the itemrenderer. This should allow me to use the same itemrenderer with different objects, as long as they have a text and image property.
Any ideas? ThanksAfter doing some research, I found my answer:
1) The data object is the current item which the List component is populated with. You can access any properties of the object using it. (Not what I'm looking for here.)
2) You can access the label property set by the labelField or labelFunction properties of the list control in the item renderer simply using this.label. This is exactly what I was looking for. -
Chnage Itemrenderer property dynamically
I am creating a simple image album. I use List control to display images. My custom Item Renderer has one Image control and label control. I like to increase and decrease Image control with the help of a HSlider control which I have placed in the panel. It should change the size of the Image when the user tracks the slider control. This is my requirement. But I am not clean how to implement this. Can anyone give some hints?
Thanks for your answer
Science I am not clear. Because Slider control and List have placed in the panel container. How can I fire event or pass vale to Item Render when user selects Hslider? I need a way to pass value to my Custom Item Render (It can event or function call) from the HSlider control. -
I would like to create child components of the component
based on a XML which is retrieved by WebService/HttpService call.
createChildren() is the one to be used to create components
dynamically. But if I use createChildren() and call a
WS/HttpService request in createChildren method, I can not get the
result of WS/HttpService request in createChildren().
It seems that the result event is processed later after
createChildren() is completed.
How can I implement my requirement?
I would appreciate any pointer or suggestion.
Best regards
Masa1) Use a List, with a custom itemRenderer
2) Use a Repeater (Probably easiest)
3) use Actionscript to addChild() components.
Tracy -
Error while saving dynamic row values of datagrid with record.
hi friends,
i am trying to add dynamic row in datagrid and save that value with record.i succeeded in first part while i am saving the record the error show like this.
errro:Property fromAmount not found on com.ci.view.Task and there is no default value.
how i resolve this error.
any suggession welcom
thanks in advance.
B.venkatesan
code:
package:
package com.ci.view
[Bindable]
public class Task
public function Task(frmAmount:String,toAmount:String,commissionPercentage:String)
this.frmAmount=frmAmount;
this.toAmount=toAmount;
this.commissionPercentage=commissionPercentage;
public var frmAmount:String;
public var toAmount:String;
public var commissionPercentage:String;
main mxml:
[Bindable]
private var tasks:ArrayCollection;
private static const ADD_TASK:String= "";
private function init():void
tasks = new ArrayCollection();
tasks.addItem(new Task("0","1000","0"));
tasks.addItem({frmAmount:ADD_TASK});
private function checkEdit(e:DataGridEvent):void
// Do not allow editing of Add Task row except for
// "Click to Add" column
if(e.rowIndex == tasks.length - 1 && e.columnIndex != 0)
e.preventDefault();
private function editEnd(e:DataGridEvent):void
// Adding a new task
if(e.rowIndex == tasks.length - 1)
var txtIn:TextInput =TextInput(e.currentTarget.itemEditorInstance);
var txtIn1:TextInput =TextInput(e.currentTarget.itemEditorInstance);
var txtIn2:TextInput =TextInput(e.currentTarget.itemEditorInstance);
var dt:Object = e.itemRenderer.data;
// Add new task
if((txtIn.text) != ADD_TASK)
var x:String=String(txtIn.text);
tasks.addItemAt(new Task("", "", ""), e.rowIndex);
// Destroy item editor
commPlanDetGrid.destroyItemEditor();
// Stop default behavior
e.preventDefault();Venktesan,
You are trying compare String and int..! which is not possible try to case the txtIn.text to int using parseInt(txtIn.text).
ORIGINAL:
if(txtIn.text != ADD_TASK).---->error : Comparison between a value with static type String and a possibly unrelated type int
tasks.addItemAt(new Task(txtIn.text, 0, ""), e.rowIndex);----> error:Implicit coercion of a value of type String to an unrelated type int.
EDITED:
if(parseInt(txtIn.text) != ADD_TASK).---->error : Comparison between a value with static type String and a possibly unrelated type int
tasks.addItemAt(new Task(parseInt(txtIn.text), 0, ""), e.rowIndex);----> error:Implicit coercion of a value of type String to an unrelated type int.
Thanks
Pradeep
Maybe you are looking for
-
Hi All, I have a transaction for getting the list of users and sending mail to them. I have used XML query to get the list of users using the following URL: "http://<server:port>/XMII/Illuminator?Service=Admin&Mode=UserList&Group=XMII Administrators
-
Hi, Can any body inform us about the special stock indicators available in SAP MNV Ramana
-
What are these keyboard apps?
Rummaging around in the Manage applications settings, I came across two apps called KeyBoardSlideUpCounter and Keytracer. Both occupy 0 bytes, and neither one has any data or cache. They both have very broad permissions on the phone, and no options t
-
URL Data Control: Connection to the URL source could not be created
Using JDev Studio 10.1.3.2 Trying to use a new URL data control pointing to a csv file. I have successfully create a new URL data control using the New Gallery->Web Services->URL Services Data Control. I have successfully tested the connection and I
-
Flash Player with Firefox--Need immediate Help!
I just came across a very odd problem happening with Firefox only. The video loads first time and plays, however if you click the next time it comes up saying cannot access/access denied, couldn't replicate in any other browser. Basically it works fi