DataGrid itemRenderer done in code?
I've searched for info on how to implement itemRenderer for a
DataGrid, and despite seeing some docs and examples, they're all
very different from what I think I want, and what I think should
also be possible.
Here's what I want: for one column (called "alert"), I want
to be able to programmatically display an appropriate image (or
even just render a character, such as "X") based on the data value
of that cell.
I would think it should be something like this:
<mx:Script>
private function RenderAlert(... ? ) :String {
if (data == "delayed") return "D"
else if (data == "canceled") return "X"
</mx:Script>
<mx:DataGrid ...>
<mx:columns>
<mx:DataGridColumn headerText="Alert" dataField="alert"
itemRenderer="RenderAlert"/>
</mx:columns>
</mx:DataGrid>
So, if anyone can point me to an example like this, I'd be
very appreciative. I'm really hoping it's possible, as all the
other methods I've seen illustrated don't appear to handle the
render decisions in code.
Thanks!
By default, I'm not exactly sure what each cell is.I'm sure
if we dug into the docs somewhere it would tell us..
I've always done any conditional stuff in my itemrenderer
component.
Specifically in the set data function which you should
override:
i.e the following is a snippet that sets a combobox
itemrenderer in a datagrid. It gets the ID of the current object
being rendered then looks it
up in an arraycollection to get the "english/display name" of
that ID then sets that as the selected item in the combo box
override public function set data(value:Object):void {
yy = this.parentApplication.AC_semesters;
if ((value != null) && (yy != null) &&
yy.length > 0) {
a_course = Course(value);
this.invalidateProperties();
for (var i:int = 0; i < yy.length; i++)
var firstItem:Object = yy.getItemAt(i);
var myid:int = a_course.crs_semester;
if (firstItem.sem_id == myid)
cb3.selectedIndex = i;
so in your case you could make up an itemrenderer component
being a label, then in your set data function, have a conditional
check to set the label.text = "X" if the value passed in is equal
to whatever.
Hope this helps...
Similar Messages
-
Move focus from one to another itemRenderer inside DataGrid itemRenderer
I have a mx: DataGrid with 4 columns that have a itemRenderer with the following settings:
- Mx:DataGrid:
<code>
<mx:DataGrid id="itensPedidoCompraList"
width="100%"
height="120"
dataProvider="{ model.pedidoCompra.itens }"
editable="true"
itemEditEnd="itensPedidoCompraList_itemEditEndHandler(event)">
</code>
- Mx:DataGridColumn:
<code>
<mx:DataGridColumn headerText="{resourceManager.getString('cadastroPedidoCompra', 'ident.PercentualDesconto') }"
width="60"
textAlign="right"
rendererIsEditor="true"
editorDataField="data">
<mx:itemRenderer>
<fx:Component>
<mx:Canvas>
<input:NumberInput width="55" number="@{ data.percentualDesconto }"/>
</mx:Canvas>
</fx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</code>
The user clicks on the line of the grid and click on the column to edit.
After him change or add value, ENTER key and have to move the focus to another column in the same line.
The way I'm doing, is moving to the column below.
What is the best way to do to move to the right column?
thank youTry adding a capture phase event listener to DataGrid for keyDown and changing the key from ENTER to TAB
-
TabIndex in DataGrid ItemRenderer Component
How to implement tabindex for the DataGrid ItemRenderer
Component?Any
idea Please."ravi_bharathii" <[email protected]> wrote
in message
news:gbv9ps$k6r$[email protected]..
> How to implement tabindex for the DataGrid ItemRenderer
Component?Any
> idea Please.
Is this what you wanted?
http://blogs.adobe.com/aharui/2008/08/datagrid_itemeditor_with_two_i.html -
DataGrid itemrenderer with switch statement
Hi,
I have datagrid control with this columns
<mx:DataGrid id="dgvParagraphs" >
<mx:columns>
<mx:DataGridColumn dataField="type" headerText="Type"/>
<mx:DataGridColumn dataField="title" headerText="Title"/>
<mx:DataGridColumn dataField="content" visible="false"/>
</mx:columns>
</mx:DataGrid>
Under type column I have values from 1 to 6. Each number presents type of content. I have icons for each type. I would like to show icon instead of just number. I know this can be done using itemrenderes but I don't know how to accomplish this.If this post answers your question or helps, please mark it as such.
Greg Lafrance
www.ChikaraDev.com
Flex Development and Support Services
You might see issues with this code during scrolling, as DataGrid recycles itemRenderers, but in that case the icon information must be in the data.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
public function getImageSource(item:Object):String{
var retVal:String;
switch(uint(item.type)){
case 1:
retVal = "black.png";
break;
case 2:
retVal = "blue.png";
break;
case 3:
retVal = "gray.png";
break;
case 4:
retVal = "green.png";
break;
case 5:
retVal = "purple.png";
break;
case 6:
retVal = "red.png";
break;
trace(retVal);
return retVal;
]]>
</mx:Script>
<mx:DataGrid id="dgvParagraphs" dataProvider="{dataXML..item}">
<mx:columns>
<mx:DataGridColumn dataField="type" headerText="Type" width="50">
<mx:itemRenderer>
<mx:Component>
<mx:Image source="{outerDocument.getImageSource(data)}" horizontalAlign="center"/>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
<mx:DataGridColumn dataField="title" headerText="Title" width="100"/>
<mx:DataGridColumn dataField="content" visible="false"/>
</mx:columns>
</mx:DataGrid>
<mx:XML id="dataXML" xmlns="">
<data>
<item>
<type>2</type>
<title>My Title 1</title>
<content>Content 1</content>
</item>
<item>
<type>5</type>
<title>My Title 2</title>
<content>Content 2</content>
</item>
<item>
<type>3</type>
<title>My Title 3</title>
<content>Content 3</content>
</item>
<item>
<type>1</type>
<title>My Title 4</title>
<content>Content 4</content>
</item>
<item>
<type>4</type>
<title>My Title 5</title>
<content>Content 5</content>
</item>
<item>
<type>6</type>
<title>My Title 6</title>
<content>Content 6</content>
</item>
<item>
<type>2</type>
<title>My Title 7</title>
<content>Content 7</content>
</item>
<item>
<type>1</type>
<title>My Title 8</title>
<content>Content 8</content>
</item>
<item>
<type>4</type>
<title>My Title 9</title>
<content>Content 9</content>
</item>
<item>
<type>5</type>
<title>My Title 10</title>
<content>Content 10</content>
</item>
<item>
<type>2</type>
<title>My Title 11</title>
<content>Content 11</content>
</item>
</data>
</mx:XML>
</mx:Application> -
DataGrid itemRenderer column problem
I have searched high and low and have not found a solution so I'm hoping someone here can help me out.
When I start up my application, my datagrid (one of the columns uses a itemrenderer) that column, displays everything but it spills / shows funky, then when I scroll some of them get fixed. I don't know exactly what causes this or how to fix it. The column I'm talking about is the "Like" column.
If code is needed I will provide a pastebin link when requested, and I have attatched a screenshot of what the problem is.
Any help / suggestions would be appreciatedUpgrade to 3.4.
Alex Harui
Flex SDK Developer
Adobe Systems Inc.
Blog: http://blogs.adobe.com/aharui -
Datagrid itemrenderer & evaluation of different column
Hey All,
I've been playing with this for a while but can't get it right. Basically, I have an itemrenderer that has an image and label, but I need to see what the value is of a different column before I know what image to use. I have a feeling the reason why my intended logic won't work is becasue the data[] does not reporesent the whole data structure...but I could be wrong.
This is what I have now:
I have a grid that references this itemrenderer & the grid dataprovider is an array collection:
Form
<s:GridColumn dataField="employee" headerText="Employee"
itemRenderer="com.mycompany.view.assets.renderers.EmployeeStatusColour"></s:GridColumn>
Item Renderer
<?xml version="1.0" encoding="utf-8"?>
<s:GridItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
....>
<fx:Script>
<![CDATA[
override public function prepare(hasBeenRecycled:Boolean):void {
//THIS WORKS BUT NEED TO ADD LOGIC
lblData.text = data[column.dataField];
statusImage.source = "com/mycompany/view/assets/images/dot_GREEN.png";
//THIS IS WHAT I WANT INSTEAD - SYNTAX BELOW IS WRONG BUT YOU'LL GET THE IDEA
lblData.text = data[column.dataField];
if(data[column(3)]; = "MONDAY"{
statusImage.source = "com/mycompany/view/assets/images/dot_GREEN.png";
}else{
statusImage.source = "com/mycompany/view/assets/images/dot_BLUE.png";
]]>
</fx:Script>
<s:HGroup verticalAlign="middle" height="100%" gap="2">
<s:Image id="statusImage"/>
<s:Label id="lblData" paddingTop="5"/>
</s:HGroup>
</s:GridItemRenderer>
Thanks in advance to anybody who can direct me to a solution.
FlexHi,
I tried your suggestion but it didn't work. Thanks though!
However, if you see the code below this works as I stated above. data[column.dataField] returns the value of the referenced value.
override public function prepare(hasBeenRecycled:Boolean):void {
lblData.text = data[column.dataField];
statusImage.source = "com/mycompany/view/assets/images/dot_green.png";
So I did a debug inside my item renderer and found that the data object had all the object values of the row from my grid, which is what I want. I just don't know how to access them individually to do my comparison. It's probably something really easy like
If (data[column(4).dataField]=="MONDAY"){
statusImage.source = "com/mycompany/view/assets/images/dot_GREEN.png";
I know I'm close just don't know the syntax.
Thanks! -
Datagrid itemRenderer - Help needed
I am having trouble getting this little bit of code working. I am trying to build an adhoc SQL generator, where the user selects the list of fields and then is able to set the WHERE criteria in a dataGrid, each row has field, criteria (ComboBox -equals, less than, etc), Low (editable), High (editable-Text or ComboBox lookup), AND/OR static ComboBox. Some of the field selections could be regular text based fields like Name and other fields selected could be lookup fields like State. I would like to be able to on rows that are TextInput render out a TextInput for LowValue and HighValue columns and for lookup fields render out a ComboBox with the dataProvider being set by a call to addComboData.
addComboData simply uses the myDataGrid.selectedItem.fieldname to determine which of the lookup table to use and assigns that collection to CBoxdataProvider. Seems simple enough but I have not been able to figure it out, some modifications seem to work, but only for a single dg cell others give me a list but does not populate lowValue but kill all other renderers. All help is appreciated.
<mx:DataGridColumn headerText="Low" rendererIsEditor="true" editorDataField="selectedItem" dataField="lowValue" textAlign="center">
<mx:itemRenderer>
<mx:Component>
<mx:HBox horizontalScrollPolicy="off" verticalScrollPolicy="off" horizontalAlign="center">
<mx:ComboBox initialize="outerDocument.addComboData()" dataProvider="{ outerDocument.CBoxdataProvider }" labelField="Description" textAlign="left" visible="{data.showCombo}" />
<mx:TextInput id="lowLabel" visible="{!data.showCombo}" />
</mx:HBox>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>Setting the selected item is not the same as a click. If you created the renderer correctly the style should change when you actually click on the item. (Does it?)
Or are you just trying to get the first row's background to be a different style when the datagrid first shows? (Initialization problem or not working at all?) -
Datagrid itemRenderer/itemEditor trouble
I have a datagrid in a Flex project, the data grid has an XML file as the source (contents below), now due to the way it is formatted (I cannot change this) some of the data I want to display is inside a tag that isnt at the initial array level. Here is the file:
<?xml version="1.0" encoding="utf-8" ?>
<Categories>
<Category>
<CategoryName>Cat 1</CategoryName>
<CategoryLink>http://www.google.com</CategoryLink>
<CategoryData>
<CategoryDescription>This is the description of category 1</CategoryDescription>
<CategoryHeader>My Category Title 1</CategoryHeader>
<CategoryNumber>1</CategoryNumber>
</CategoryData>
</Category>
</Categories>
I need to display CategoryName, CategoryLink, CategoryData.CategoryDescription, CategoryData.CategoryNumber.
Now I blindly dropped the datagrid into the project and bound it to the data source, I get the following returned for CategoryData:
[object CategoryData_type]
Not much use, but with what appears to be a hack I changed the code for the column to read dataField="CategoryData.CategoryDescription", and hooray it works. I didnt realise at the time that this was wrong, and when I dropped in an itemEditor things went wrong. When the datagrids load they display the correct data, but then when you try to edit any of the child property fields you get the following error:
ReferenceError: Error #1069: Property CategoryData.CategoryDescription not found on valueObjects.Category_type and there is no default value.
I have looked up the error and I realise that it means that there is no value for CategoryData.CategoryDescription, but if I can display it why can i not edit it! What do I have to do to make this work?
Anyway, here is the code, it shows the default bound datagrid, a second datagrid with the hack applied, and a third hacked datagrid with an itemRenderer and itemEditor on the number columns
Can you please take a look and tell me what I did wrong, well more to the point, if there is a doc that explains how to deal with XML like this then please point me at it.
I did try changing the return type for ANY of the columns, but this fails, I also tried a labelFunction, but again I can get the [object CategoryData_type] to display, but I get the null reference exception as the datagrid loads if I try to get to the child props.
Here is the Flex code:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:categories="services.categories.*"
minWidth="955" minHeight="600">
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.events.FlexEvent;
protected function dataGrid_creationCompleteHandler(event:FlexEvent):void
getDataResult.token = categories.getData();
protected function lftest(item:Object, column:GridColumn):String
var t:String = item.CategoryData;
return t;
]]>
</fx:Script>
<fx:Declarations>
<s:CallResponder id="getDataResult"/>
<categories:Categories id="categories"
fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)"
showBusyCursor="true"/>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:DataGrid id="dataGrid" x="10" y="10" width="684"
creationComplete="dataGrid_creationCompleteHandler(event)" editable="true"
requestedRowCount="4">
<s:columns>
<s:ArrayList>
<s:GridColumn width="100" dataField="CategoryName" headerText="CategoryName"></s:GridColumn>
<s:GridColumn width="100" dataField="CategoryLink" headerText="CategoryLink"></s:GridColumn>
<s:GridColumn width="180" dataField="CategoryData" headerText="CategoryData"></s:GridColumn>
</s:ArrayList>
</s:columns>
<s:typicalItem>
<fx:Object CategoryData="CategoryData1" CategoryLink="CategoryLink1"
CategoryName="CategoryName1"></fx:Object>
</s:typicalItem>
<s:AsyncListView list="{getDataResult.lastResult}"/>
</s:DataGrid>
<s:DataGrid id="dataGrid2" x="10" y="147" width="684" editable="true" requestedRowCount="4">
<s:columns>
<s:ArrayList>
<s:GridColumn width="100" dataField="CategoryName" headerText="CategoryName"></s:GridColumn>
<s:GridColumn width="100" dataField="CategoryLink" headerText="CategoryLink"></s:GridColumn>
<s:GridColumn width="180" dataField="CategoryData" headerText="CategoryData"></s:GridColumn>
<s:GridColumn dataField="CategoryData.CategoryDescription" headerText="Desc"></s:GridColumn>
<s:GridColumn dataField="CategoryData.CategoryHeader" headerText="Head"></s:GridColumn>
<s:GridColumn dataField="CategoryData.CategoryNumber" headerText="Num"></s:GridColumn>
</s:ArrayList>
</s:columns>
<s:typicalItem>
<fx:Object CategoryData="CategoryData1" CategoryLink="CategoryLink1"
CategoryName="CategoryName1"></fx:Object>
</s:typicalItem>
<s:AsyncListView list="{getDataResult.lastResult}"/>
</s:DataGrid>
<s:DataGrid id="dataGrid3" x="10" y="284" width="684" editable="true" requestedRowCount="4">
<s:columns>
<s:ArrayList>
<s:GridColumn width="100" dataField="CategoryName" headerText="CategoryName"></s:GridColumn>
<s:GridColumn width="100" dataField="CategoryLink" headerText="CategoryLink"></s:GridColumn>
<s:GridColumn width="180" dataField="CategoryData" headerText="CategoryData"></s:GridColumn>
<s:GridColumn headerText="Number">
<s:itemRenderer>
<fx:Component>
<s:GridItemRenderer>
<s:NumericStepper value="{data.CategoryData.CategoryNumber}" />
</s:GridItemRenderer>
</fx:Component>
</s:itemRenderer>
</s:GridColumn>
<s:GridColumn dataField="CategoryData.CategoryNumber" headerText="Number">
<s:itemEditor>
<fx:Component>
<s:GridItemEditor>
<s:NumericStepper value="{data.CategoryData.CategoryNumber}" />
</s:GridItemEditor>
</fx:Component>
</s:itemEditor>
</s:GridColumn>
</s:ArrayList>
</s:columns>
<s:typicalItem>
<fx:Object CategoryData="CategoryData1" CategoryLink="CategoryLink1"
CategoryName="CategoryName1"></fx:Object>
</s:typicalItem>
<s:AsyncListView list="{getDataResult.lastResult}"/>
</s:DataGrid>
</s:Application>
All and any advice welcome.
ShaineOne last try, I now know for sure that the data in the file is loading, I created a labelFunction on the CategoryDescription column that looks like this:
protected function dispData(item:Object, column:GridColumn):String
var t:Object = item.CategoryData;
var s:String = item.CategoryData.CategoryDescription;
return s;
Because it returns s, which I now know is undefined (which is the problem!) I managed to get a debug output. As you can see the value of t is the categorydata, and it appears to have the 3 values I need to get access to, but I have no idea how to do this. I also changed the function to read:
protected function dispData(item:Object, column:GridColumn):String
var t:Object = item.CategoryData;
var s:String = t.CategoryDescription;
return s;
But this undefines t and s! Very confused
this test2 (@d2e10a1)
item valueObjects.Category_type (@91f8a51)
[inherited]
column spark.components.gridClasses.GridColumn (@d61b239)
t valueObjects.CategoryData_type (@91f8c11)
[inherited]
_cacheInitialized_isValid false
CategoryDescription "This is the description of category 1"
CategoryHeader "My Category Title 1"
CategoryNumber "1"
_changedObjects mx.collections.ArrayCollection (@d5d9e41)
_changeWatcherArray [] (@cfab061)
_dminternal_model _CategoryData_typeEntityMetadata (@d4286a1)
_doValidationCacheOfCategoryDescription null
_doValidationCacheOfCategoryHeader null
_doValidationCacheOfCategoryNumber null
_doValidationLastValOfCategoryDescription null
_doValidationLastValOfCategoryHeader null
_doValidationLastValOfCategoryNumber null
_internal_CategoryDescription "This is the description of category 1"
_internal_CategoryHeader "My Category Title 1"
_internal_CategoryNumber "1"
_invalidConstraints [] (@ca50fd9)
invalidConstraints_der <setter>
_isValid false
isValid_der <setter>
managingService <setter>
_managingService null
_model _CategoryData_typeEntityMetadata (@d4286a1)
_validationFailureMessages [] (@cfab0b1)
s undefined
As always all help welcome.
Shaine
Message was edited after a oops moment by: ProcessEndNow -
Enable disable linkbar links in datagrid itemrenderer.
Hi All,
I have to show the linkbar in datagrid column as a renderer and enable and disable the links according to attached documents codes.
here are my sample code
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init();">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
[Bindable]
public var arrColl:ArrayCollection = new ArrayCollection();
public function init():void{
arrColl.addItem(["1,2,3","1,2"]);
arrColl.addItem(["1,2,3", "1,3"]);
arrColl.addItem(["1,2,3","1,2"]);
arrColl.addItem(["1,2,3", "1,3"]);
arrColl.addItem(["1,2,3","1,2"]);
arrColl.addItem(["1,2,3", "1,3"]);
arrColl.addItem(["1,2,3","1,2"]);
arrColl.addItem(["1,2,3", "1,3"]);
arrColl.addItem(["1,2,3","1,2"]);
arrColl.addItem(["1,2,3", "1,3"]);
arrColl.addItem(["1,2,3","1,2"]);
arrColl.addItem(["1,2,3", "1,3"]);
arrColl.addItem(["1,2,3","1,2"]);
arrColl.addItem(["1,2,3", "1,3"]);
arrColl.addItem(["1,2,3","1,2"]);
arrColl.addItem(["1,2,3", "1,3"]);
arrColl.addItem(["1,2,3","1,2"]);
arrColl.addItem(["1,2,3", "1,3"]);
arrColl.addItem(["1,2,3","1,2"]);
arrColl.addItem(["1,2,3", "1,3"]);
arrColl.addItem(["1,2,3","1,2"]);
arrColl.addItem(["1,2,3", "1,3"]);
arrColl.addItem(["1,2,3","1,2"]);
arrColl.addItem(["1,2,3", "1,3"]);
arrColl.addItem(["1,2,3","1,2"]);
arrColl.addItem(["1,2,3", "1,3"]);
arrColl.addItem(["1,2,3","1,2"]);
arrColl.addItem(["1,2,3", "1,3"]);
arrColl.addItem(["1,2,3","1,2"]);
arrColl.addItem(["1,2,3", "1,3"]);
arrColl.addItem(["1,2,3","1,2"]);
arrColl.addItem(["1,2,3", "1,3"]);
arrColl.addItem(["1,2,3","1,2"]);
arrColl.addItem(["1,2,3", "1,3"]);
arrColl.addItem(["1,2,3","1,2"]);
arrColl.addItem(["1,2,3", "1,3"]);
arrColl.addItem(["1,2,3","1,2"]);
arrColl.addItem(["1,2,3", "1,3"]);
arrColl.addItem(["1,2,3","1,2"]);
arrColl.addItem(["1,2,3", "1,3"]);
arrColl.addItem(["1,2,3","1,2"]);
arrColl.addItem(["1,2,3", "1,3"]);
arrColl.addItem(["1,2,3","1,2"]);
arrColl.addItem(["1,2,3", "1,3"]);
arrColl.addItem(["1,2,3","1,2"]);
arrColl.addItem(["1,2,3", "1,3"]);
]]>
</mx:Script>
<mx:DataGrid id="dg" dataProvider="{arrColl}" width="200" height="500" x="510" y="168" >
<mx:columns>
<mx:DataGridColumn itemRenderer="assets.components.linkbarItemRenderer" />
</mx:columns>
</mx:DataGrid>
</mx:Application>
My item renderer linkbarItemRenderer.mxml as
<?xml version="1.0" encoding="utf-8"?>
<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%" creationComplete="init();" >
<mx:Script>
<![CDATA[
import mx.controls.LinkButton;
import mx.collections.ArrayCollection;
import mx.controls.Alert;
[Bindable] public var arrColl : ArrayCollection = new ArrayCollection();
public var arrDocType : ArrayCollection = new ArrayCollection([{data:"1" , label:"AP"},{data:"2" , label:"AR"},{data:"3" , label:"BOL"}]);
public var attDoccodes : Array;
public function init():void
try
var requiredDoc :String = data[0];
var attachDoc : String = data[1];
var reqDocCodes :Array = requiredDoc.split(",");
attDoccodes = attachDoc.split(",");
if(reqDocCodes != null)
//add the links of required documents.
for(var i:int = 0 ; i<reqDocCodes.length; i++ )
var obj:Object = new Object();
for(var j : int = 0; j < arrDocType.length; j++)
if(arrDocType.getItemAt(j).data == reqDocCodes[i])
obj.label = arrDocType.getItemAt(j).label;
obj.data = reqDocCodes[i];
arrColl.addItem(obj);
callLater(enableDisalbeLinks);
catch(error:Error)
Alert.show("error ::"+error.getStackTrace());
public function enableDisalbeLinks():void
try
//disable all links first
for(var q:int=0; q< arrColl.length; q++)
LinkButton(linkBarId.getChildAt(q)).enabled = false;
if(attDoccodes != null)
for(var k:int = 0; k<attDoccodes.length; k++)
for(var l:int = 0 ; l<arrColl.length; l++)
if(arrColl.getItemAt(l).data == attDoccodes[k])
LinkButton(linkBarId.getChildAt(l)).enabled = true;
catch(error:Error)
Alert.show("error ::"+error.getStackTrace());
]]>
</mx:Script>
<mx:LinkBar id="linkBarId" dataProvider="{arrColl}" />
</mx:HBox>
It renderes the link in correct form in datagrid first time.when i scroll the datagrid the rows are miss up with each other and links are not shown propers in enable/disable format.
Thanks,
Amol.Hi All,
It was my fault. Got it work now.
When I redirect to PR, it also calls my page initialization method and clear all data. I added a parameter and issue resolved.
Thanks & Regards,
KJ -
Problem with Datagrid itemrenderer with a Datagrid
Hi all,
I have this kind of a structure. I try to use a datagrid item renderer in a data grid column. However when I try to move rows inside the same datagrid I experience a problem. When my datagrid loads first it seems correct, but when I drag and drop a row in the same datagrid inner datagrids start to be drew in wrong rows. I checked the DB but there are no mistakes in DB records. Problem is with rendering. I suppose inner datagrids trying to draw to early or datagrid component is trying to reuse the itemrenderer. I could not find any solutions for that. Any help will be greatly appreciated..
<mx:DataGridColumn width="130" editable="false"
headerText="{resourceManager.getString('resources', 'acl.content')}">
<mx:itemRenderer>
<mx:Component>
<ACLInnerDataGrid rowCount="3" dragEnabled="true" dropEnabled="false"
x="0" y="0" editable="true" dragInitiatorId="catGrid"
filterGroupName="content" remoteDestination="zend"
remoteSource="ACLFilterParamService" showHeaders="false"
creationComplete="this.init();">
<columns>
<mx:DataGridColumn dataField="id" editable="false" visible="false"/>
<mx:DataGridColumn dataField="ruleId" editable="false" visible="false"/>
<mx:DataGridColumn dataField="filterKey" editable="false" visible="false"/>
<mx:DataGridColumn dataField="param" editable="false" visible="false"/>
<mx:DataGridColumn dataField="name" editable="true"/>
</columns>
</ACLInnerDataGrid>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
Thanks in advance.I have attached the item renderer component source code.
-
I have created a datagrid which has suppose 4 columns out of which 1 has an option of setting as favorite just like we have in our every mail servers (gmail, yahoo, outlook, etc). I have used a linkbutton as an item renderer and its toggle property as true. so wenever i click on it its getting selected and i have used skin for selected and normal state which is a star.
The problem is that when data length exceeds and scrollbar comes in datagrid and whenever i scroll down and up the stars which are not selected are getting selected or in some scenarios the whole column stars get selected.
How to get rid of this problem ?Can I see the itemrenderer code. I'm assuming that you aren't clearing the values from previous objects in you
override protected function set data( value:Object ):void call.
Sincerely ,
Ubu/ -
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. -
Datagrid itemrenderer list rowcount not changing with data
I have a datagrid with an itemrenderer. the itemrenderer is a list component. I populate the list with different values for each datagrid row. this works fine. However, I want the list to reset the rowcount for each datagrid row. This is not happening. if the first datagrid row list box is 3 rows every list box in that column is 3 rows no matter what i do. here's my code:
<mx:List xmlns:mx="http://www.adobe.com/2006/mxml" rowCount="1">
<mx:Script>
<![CDATA[
import mx.utils.ObjectProxy;
import mx.collections.ArrayCollection;
import mx.utils.ArrayUtil;
[Bindable] private var arr:Array;
override public function set data( value:Object ) : void
super.data = value;
if(value != null && value.MEET is ArrayCollection)
var len:Number = value.MEET.length;
arr = new Array();
for each (var obj:ObjectProxy in value.MEET){
arr.push(obj.DAYS);
this.dataProvider = arr;
//labelField = "DAYS";
this.rowCount = len;
else if (value != null && value.MEET is ObjectProxy )
this.rowCount = 1;
this.dataProvider = value.MEET;
this.labelField = "DAYS";
else
this.rowCount = 1;
]]>
</mx:Script>
</mx:List>Hello !
This trick makes my application freeze...
I've just an advancedDatagrid populated with arrays, and a list as renderer on some of its columns... I've got exactly the same problem (rowCount that is always the same, for all of my renderers instances), but your solution doesn't work it out...
Any idea ?
thanks a lot -
Datagrid ItemRenderer with LinkButton.
I have one of the columns in my DataGrid which needs to be a LinkButton. The actual data value is 0 or 1 but I want the LinkButton to be visible only if the data value is 1. The problem is that LinkButton is always visible. How can I selectively make it visible or invisible on different rows of DataGrid ? I tried making the visible attribute bound with the value of the flag but no success.
<mx:DataGridColumn itemRenderer="LinkButtonItemRenderer" dataField="flag" />
Following is the LinkButtonItemRenderer code.
<mx:LinkButton xmlns:mx="http://www.adobe.com/2006/mxml" visible="{data.flag == 1}" label="Click Me" />Hi MoreGart,
You can try this...
<mx:LinkButton xmlns:mx="http://www.adobe.com/2006/mxml" render="(Number(data.flag) == 1)?(visible = true):(visible = false)" label="Click Me" />
Try this ans let me know...
Thanks,
Bhasker -
DataGrid, itemRenderer, viewStacks
I am using an inline itemRenderer for an image on a Datagrid
which rests in a viewStack. However, if the Datagrid is not in the
first index of the viewStack the itemRenderer will not load. I've
tried changing the creationPolicy of the viewStack with no avail.
Any ideas?
Thanks
RubenIn the following code (modified version of yours) if you
remove enabled="false" from the milestoneGrid datagrid it seems to
work:
<?xml version="1.0"?>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
height="200">
<mx:ArrayCollection id="statusData">
<mx:Object>
<mx:itemLabel>M1</mx:itemLabel>
<mx:schedDate>01/01/2008</mx:schedDate>
<mx:startDate>01/01/2008</mx:startDate>
<mx:endDate>01/10/2008</mx:endDate>
<mx:user>Bob Smith</mx:user>
<mx:status>overdue</mx:status>
</mx:Object>
<mx:Object>
<mx:itemLabel>M2</mx:itemLabel>
<mx:schedDate>01/01/2008</mx:schedDate>
<mx:startDate>01/01/2008</mx:startDate>
<mx:endDate>01/10/2008</mx:endDate>
<mx:user>Bob Smith</mx:user>
<mx:status>overdue</mx:status>
</mx:Object>
<mx:Object>
<mx:itemLabel>M3</mx:itemLabel>
<mx:schedDate>01/01/2008</mx:schedDate>
<mx:startDate>01/01/2008</mx:startDate>
<mx:endDate>01/10/2008</mx:endDate>
<mx:user>Bob Smith</mx:user>
<mx:status>overdue</mx:status>
</mx:Object>
<mx:Object>
<mx:itemLabel>M4</mx:itemLabel>
<mx:schedDate>01/01/2008</mx:schedDate>
<mx:startDate>01/01/2008</mx:startDate>
<mx:endDate>01/10/2008</mx:endDate>
<mx:user>Bob Smith</mx:user>
<mx:status>overdue</mx:status>
</mx:Object>
<mx:Object>
<mx:itemLabel>M5</mx:itemLabel>
<mx:schedDate>01/01/2008</mx:schedDate>
<mx:startDate>01/01/2008</mx:startDate>
<mx:endDate>01/10/2008</mx:endDate>
<mx:user>Bob Smith</mx:user>
<mx:status>overdue</mx:status>
</mx:Object>
<mx:Object>
<mx:itemLabel>M6</mx:itemLabel>
<mx:schedDate>01/01/2008</mx:schedDate>
<mx:startDate>01/01/2008</mx:startDate>
<mx:endDate>01/10/2008</mx:endDate>
<mx:user>Bob Smith</mx:user>
<mx:status>overdue</mx:status>
</mx:Object>
<mx:Object>
<mx:itemLabel>M7</mx:itemLabel>
<mx:schedDate>01/01/2008</mx:schedDate>
<mx:startDate>01/01/2008</mx:startDate>
<mx:endDate>01/10/2008</mx:endDate>
<mx:user>Bob Smith</mx:user>
<mx:status>overdue</mx:status>
</mx:Object>
<mx:Object>
<mx:itemLabel>M8</mx:itemLabel>
<mx:schedDate>01/01/2008</mx:schedDate>
<mx:startDate>01/01/2008</mx:startDate>
<mx:endDate>01/10/2008</mx:endDate>
<mx:user>Bob Smith</mx:user>
<mx:status>overdue</mx:status>
</mx:Object>
</mx:ArrayCollection>
<mx:HBox borderStyle="solid">
<mx:Button label="Datagrid One"
click="gridVS.selectedChild=dg1;"/>
<mx:Button label="Datagrid Two"
click="gridVS.selectedChild=dg2;"/>
</mx:HBox>
<mx:ViewStack id="gridVS" width="100%" height="100%"
creationPolicy="all">
<mx:VBox id="dg1" width="100%" height="100%"
verticalScrollPolicy="off" horizontalScrollPolicy="off">
<mx:DataGrid id="milestoneGrid" height="100%"
styleName="myDataGrid"
width="100%" dataProvider="{statusData}" rowCount="8"
variableRowHeight="true" enabled="false">
<mx:columns>
<mx:Array>
<mx:DataGridColumn dataField="itemLabel"
headerText="Milestone" width="120"/>
<mx:DataGridColumn dataField="schedDate"
headerText="Scheduled Start Date" width="120"/>
<mx:DataGridColumn dataField="startDate"
headerText="Started"/>
<mx:DataGridColumn dataField="status"
headerText="Status"/> <mx:DataGridColumn dataField="endDate"
headerText="Completed"/>
</mx:Array>
</mx:columns>
</mx:DataGrid>
</mx:VBox>
<mx:VBox id="dg2" width="100%" height="100%">
<mx:DataGrid id="areaGrid" styleName="myDataGrid"
width="100%" height="100%"
selectable="true" rowCount="8" dataProvider="{statusData}"
enabled="true"
editable="false" variableRowHeight="true" >
<mx:columns>
<mx:Array>
<mx:DataGridColumn dataField="itemLabel" headerText="Area"
width="270" wordWrap="true"/>
<mx:DataGridColumn dataField="startDate"
headerText="Started"/>
<mx:DataGridColumn dataField="endDate"
headerText="Completed"/>
<mx:DataGridColumn dataField="status"
headerText="Status"/>
<mx:DataGridColumn dataField="user" headerText="Run
By"/>
</mx:Array>
</mx:columns>
</mx:DataGrid>
</mx:VBox>
</mx:ViewStack>
</mx:Application>
Maybe you are looking for
-
my client running fg sub contracting (electro plating )cycle through the MRP after return from vendor with mvt type 105 (543) i check document list with MB51. i found following g/l account effects : SFG consumption for sub contract account = 602026
-
Self-assigned IP - No connection
I have a perfectly fine IP address when I'm hardwired, and a full signal, but no internet connection. Here's the steps I've taken. What am I missing? -Obtained a valid IP address and connection by connecting my Powerbook G4 to my cable modem via ethe
-
How do i close a page that says hit close to continue and cancel to stay on the page?
-
Hi Can we install SQL Server 2014 std on a server which already has 2008 std installed so we can migrate 2008 apps gradually? Thanks Regads
-
I have some sample code for string editing using regular expressions but I'm a little confused as to it's behavior. Here's what I have: public class WordFixer protected final String PUNC_MATCH = "[\\d\\p{Punct}]+"; protected final String PUNC