A datagrid control creating reusable sortCompareFunction

People,

I was looking to write a re-usable sortCompareFunction for use with the DataGrids, but I think I'm missing something obvious.  A comparison function sorts has a signature that looks like:

function mySort (obj1: object, obj2: Object): int

Now suppose the data for the grid contains objects that have fields 'A', 'B' and 'C '.

When the mySort() function is called to sort the data, it seems not that I know what column / field in the data of the kind should apply to.  It seems to me that I have to write three functions, one for 'A', a 'B' and one for 'C' and define each of them to the sortCompareFunction for the corresponding column.  But in my solution, I can't do that I have a variable/dynamic number of columns and don't know the name of the field in the object that I need to sort on advance.

Neil

I guess you could always take this approach

http://www.Adobe.com/cfusion/CommunityEngine/index.cfm?event=ShowDetails&ProductID=2&postI d = 8047

for example

public void doSortForField(field:String):Function
{
return function(obj1:Object,_obj2:Object):int
{
Return mx.utils.ObjectUtil.stringCompare (obj1 [field],
obj2 [Field], true);
}
}

And extend the method (or establish a class) to support an array of fields rather than a single field.

Bonus points for also support different types.

-Corey Lucier

Tags: Flex

Similar Questions

  • Problem of filling and creating a dynamic DataGrid control

    Hello

    I have a scenario eventually, and I'm desperate that anyone who reads this message might help me. I have a table in what follows I would use its individual child element as the data in each column.

    I wonder if someone can provide some guidance on how I can do this, because I can't fill in the data, and so he keeps throwing the error unable to create a new column to me.

    Can someone help me please?

    Thanks in advance.

    The code is attached.

    Alice

    "alice_data" wrote in message
    News:gn5fli$20D$1@forums. Macromedia.com...
    > Hi, Amy:
    >
    > I want to say is that I intend to create a DataGrid that contains all the
    > I've specified in dg.columns = ['region_name', 'population',
    [> 'market'];

    The DataGrid columns table must contain column objects, not strings.

    > However, since all values are generated dynamically, I could
    > probably
    > only to add a column to the times, but I want to add all columns to
    > a
    > dataGrid unique instead of create a DataGrid for each of the columns.
    > With my
    > structure current codes, I think that I create something with the individual
    > columns
    > on each of the new dataGrids.

    Each object on the display list can have only one parent. As the saying
    go, you cannot have your cake and eat it, too. Or put in a more
    metaphor of everyday, if you paid your red shoes to Martha, you cannot also
    Wear them. So IFI am you understand, you want to create a
    DataGrid with multiple columns, and then use these columns in several
    DataGrids? It is not possible.

    > Did I do something wrong to try to reach what I wanted to do? With
    > a
    > DataGrid with multiple columns?

    It is quite possible to have several columns in a DataGrid control. It's
    What to do in datagrids. And of course if your code does not achieve what you set
    to do this, it is a problem. It's just very difficult to determine exactly
    where your problem lies.

    You can find this useful example
    http://blog.flexexamples.com/2008/03/04/dynamically-adding-new-columns-to-a-DataGrid-contr ol in flex.

  • DataGrid: can I recover the data, BUT it does not show the datagrid control

    Hello

    Hi - I've traced data through php mysql in actionscript but it does not show the datagrid control. Here is my code.

    Import fl.controls.DataGrid;

    Import fl.controls.dataGridClasses.DataGridColumn;

    Import fl.data.DataProvider;

    Import fl.controls.ScrollPolicy;

    Import fl.managers.StyleManager; necessary to format the text in cells

    import flash.display.MovieClip;

    import flash.net.URLRequest;

    import flash.events.Event;

    import flash.events.MouseEvent;

    import flash.net.URLLoader;

    to import flash.net.URLVariables;

    import flash.net.URLRequestMethod;

    import flash.net.URLLoaderDataFormat;

    Create a new instance of the DataGrid component.

    var aDg:DataGrid = new DataGrid();

    var myDp:Array = new Array();

    var myData:URLRequest = new URLRequest ("http://www.cambridgekids.es/kglad/php/getUsers.php");

    myData.method = URLRequestMethod.POST;

    var loader: URLLoader = new URLLoader();

    loader.dataFormat = pouvez;

    loader.addEventListener (Event.COMPLETE, dataOnLoad);

    Loader.Load (mydata);

    function dataOnLoad(evt:Event) {}

    for (var i: uint = 0; i < evt.target.data.cant; i ++) {}

    myDp.push ({number: evt.target.data ["firstname" + i], Apellido:evt.target.data["lastname"+i]});})

    / / trace (evt.target.data ["firstname" + i]);

    }

    myDp.dataProvider = new DataProvider (myDp);

    }

    aDg.dataProvider = new DataProvider (myDp);

    aDg.columns = ['number', 'Apellido'];

    aDg.setSize (800,300);

    aDg.move (150,200);

    aDg.rowHeight = 40; / / allows 2 lines of text in the default text size.

    aDg.columns [0] .width = 80;

    aDg.columns [1] .width = 30;

    aDg.resizableColumns = true;

    aDg.verticalScrollPolicy = ScrollPolicy.AUTO;

    addChild (aDg);

    DOH! I thought I was in the flex forum so ignore my previous answer.

    You must set the dataProvider on the dg after completing the dataprovider with data so spend aDg.dataProvider = new DataProvider (myDp); at the end of the dataOnLoad method

  • Retrieve data from the datagrid control

    Hi people,

    Currently I'm trying to create a datagrid control that allows the user to see the view of all data. And allow the user to click the data grid and a popup displays a more detailed information data

    But I have some problem to retrieve the id of the data first. I managed to create a click event to allow the user to click a specific popup data and shows.

    I need help regarding this. Thank you

    -ExpertDiscoverySystem.mxml-

    [Bindable]
    public var dataid:String;
    private void onItemClick (e:ListEvent): void {}
    currentState = "SearchName;
    Add here the popup, then try to transfer a certain area to display all necessary data
    titleWindow = PopUpManager.createPopUp (Thi, component. DataDetail, true) as TitleWindow;
    PopUpManager.bringToFront (titleWindow);
    var dataid:String = e.currentTarget.selectedTarget.id;
    }

    < mx:Panel put width = "1169" height = "558" layout = "absolute" title = "Datagrid" x = "48.7" y = '171.65' includeIn 'SearchResult' = >
    < mx:Label horizontalCenter = "0" y = "1" text = 'results '.
    fontSize = "16" fontWeight = "bold" / >
    < mx:DataGrid id = "dgPeeps" width = '1141' height = '487' selectedIndex = '0' showHeaders = 'false' "16.6" = x y = '24' creationComplete = "dgPeeps_creationCompleteHandler (event)" itemClick = "onItemClick (event); "dataProvider ="{getContentForAllResult.lastResult}">
    < mx:columns >
    < mx:DataGridColumn dataField = "img" itemRenderer = "component.image" / >
    < mx:DataGridColumn headerText = "name" dataField = "name" / >
    < mx:DataGridColumn headerText = "Department" dataField = "department" / >
    < mx:DataGridColumn headerText = "expert" dataField = "expert" / >
    < mx:DataGridColumn headerText = "project" dataField = "project" / >
    < mx:DataGridColumn dataField = "id" / >
    < / mx:columns >
    < / mx:DataGrid >
    < / mx:Panel >

    -DataDetail.mxml - the popup component

    <? XML version = "1.0" encoding = "utf-8"? >
    " < = xmlns:fx s:TitleWindow ' http://ns.Adobe.com/MXML/2009 "
    xmlns:s = "library://ns.adobe.com/flex/spark".
    xmlns:MX = "library://ns.adobe.com/flex/mx" width = "700" height = "600" backgroundColor = "#000000" backgroundAlpha = '0,70' close = "titleWindow_close (event)" xmlns:services = "*" services > "
    < fx:Declarations >
    < s:CallResponder id = "getSpecificResultResult" / >
    < services: ExpertSearchManager id = "expertSearchManager" fault = "Alert.show (event.fault.faultString +"\n"+ event.fault.faultDetail)" showBusyCursor = "true" / > "
    <! - Place non-visual elements (e.g., services, items of value) here - >
    < / fx:Declarations >

    < fx:Script >
    <! [CDATA]
    Import mx.controls.Alert;
    Import mx.core.FlexGlobals;
    Import mx.events.CloseEvent;
    Import mx.events.FlexEvent;
    Import mx.managers.PopUpManager;

    [Bindable]

    private void titleWindow_close(evt:CloseEvent):void {}
    PopUpManager.removePopUp (this)
    }

    protected function dataGrid_creationCompleteHandler(event:FlexEvent):void
    {
    change below with Dynamics
    var dataid:String;
    dataID = FlexGlobals.topLevelApplication.id;
    getSpecificResultResult.token = expertSearchManager.getSpecificResult (dataid);
    }

    []] >
    < / fx:Script >

    < mx:Image x = "10" y = "10" width = "67" height = "67" / >
    < s:Label = "85" x = "10" text = "Label" color = "#FFFFFF" / >
    < s:Label = "125" x = "10" text = "Label" color = "#FFFFFF" / >
    < s:Label = "85" x y = "30" text = "Age" color = "#FFFFFF" / >
    < s:Label = "114" x y = "30" text = "Label" color = "#FFFFFF" / >
    < mx:HRule x = "0" y = "109" width = "697" / >
    < mx:HRule x = "0" y = "256" width = "698" / >
    < mx:VRule = "256" x = "114" height = "141" / >
    < s:Label x = "10" y = "119" text = "Social Networking" color = "#FFFFFF" fontWeight = "bold" fontSize = "14" / >
    < s:Label x = "10" y = "270" text = "Relationship" color = "#FFFFFF" fontWeight = "bold" fontSize = "14" / >
    < s:Label = "270" x = "119" text = 'Skills' color = "#FFFFFF" fontWeight = "bold" fontSize = "14" / >
    < mx:Image = "4" x = "151" source = "images/twitter.gif" width = "85" height = "21" / > "
    < mx:Image = "6" x = "199" source = "images/facebook.jpg" width = "85" height = "21" / > "
    < s:Label = "99" x = "160" text = "Label" color = "#FFFFFF" / >
    < s:Label = "99" x = "208" text = "Label" color = "#FFFFFF" / >
    < mx:DataGrid = "283" x = "376" id = "dataGrid" creationComplete = "dataGrid_creationCompleteHandler (event)" dataProvider = "{getSpecificResultResult.lastResult}" > "
    < mx:columns >
    < mx:DataGridColumn headerText = "id" dataField = "id" / >
    < mx:DataGridColumn headerText = "expert" dataField = "expert" / >
    < mx:DataGridColumn headerText = "project" dataField = "project" / >
    < mx:DataGridColumn headerText = "searchTerm" dataField = "searchTerm" / >
    < mx:DataGridColumn headerText = "searchCriteria" dataField = "searchCriteria" / >
    < mx:DataGridColumn headerText = "Department" dataField = "department" / >
    < mx:DataGridColumn headerText = "name" dataField = "name" / >
    < mx:DataGridColumn headerText = "img" dataField = "img" / >
    < / mx:columns >
    < / mx:DataGrid >

    < / s:TitleWindow >

    It should work fine if you did changes properly. You will see directly the _dataid of the property which you type titleWindow. through code intellisense.

    As because you stated a public variable it must defenitely be accessible for the titleWindow instance. Please cross-check you do not have something wrong.

    Thank you

    Jean Claude

  • Change the color of an individual cell after editing in a datagrid control

    Hi all, I have tried with the custom converter but its either change the entire grid or the entire column. Is it possible to solve this problem by applying the element converter to a particular area? Help needed please...


    Thanks in advance

    I did a bit of work on this and discovered some things that make it a little hard.

    Let's start with the application and the DataGrid control. You will need to know whether or not the currently edited cell value has changed. To do this, I created a variable called oldValue. I then added two event handlers for the DataGrid control:

    itemEditBeginning = "rememberValue (event)" "
    itemEditEnd = "markCell (event)" "

    In the rememberValue function, I copied the value in the cell for the oldValue:

    private function rememberValue (event: DataGridEvent): void
    {
    oldValue = dp [event.rowIndex] [event.dataField];
    }

    In markCell, I have determined if the value has changed. If so, I placed his index of row/column on a list or I removed it from the list:

    private function markCell (event: DataGridEvent): void
    {
    If (event.reason == DataGridEventReason.CANCELLED) {}
    return;
    }

    var newValue:String =
    TextInput (event.currentTarget.itemEditorInstance) .text;

    If (oldValue! = Number (newValue)) {}
    HilightEditedCellRenderer.addCell (event.rowIndex, event.columnIndex);
    } else {}
    HilightEditedCellRenderer.removeCell (event.rowIndex, event.columnIndex);
    }
    }

    HilightEditedCellRenderer is the itemRenderer to my cells. AddCell and removeCell functions are static members of the cell.

    In the HilightEditedCellRenderer, I created an ArrayCollection collection to contain the list of cells and the following functions:

    public static var editedCells:ArrayCollection = new ArrayCollection();

    isEditedCell determines if the row/column is in the collection editedCells.

    public static void isEditedCell (rowIndex:Number, columnIndex:Number): int
    {
    for (var j: int = 0; j< editedcells.length;="">
    {
    If (rowIndex == editedCells [j] .rowIndex & columnIndex == .columnIndex editedCells [j])
    {
    return j;
    }
    }

    Returns - 1;
    }

    removeCell deletes the row/column index within the collection of editedCells pair
    public static void removeCell (rowIndex:Number, columnIndex:Number): void
    {
    determine whether the cell is already on the list and if so, remove it
    var int index = isEditedCell (rowIndex, columnIndex);
    If (index > = 0) {}
    editedCells.removeItemAt (index);
    }
    }

    Add cell place the row/column pair in the Collection if they are not already:
    public static void addCell (rowIndex:Number, columnIndex:Number): void
    {
    Make sure that the cell does not exist yet - don't want to add twice
    If (isEditedCell (rowIndex, columnIndex)< 0="" )="">
    editedCells.addItem ({rowIndex:rowIndex, columnIndex:columnIndex});})
    }
    }
    Finally, I replace the data set function to change the color:

    override public function set data(value:Object):void
    {
    Super.Data = value;

    If (listData)
    {
    Determine the first visible line and a visible column

    var firstRow:Number = .verticalScrollPosition (listData.owner as DataGrid);
    var firstCol:Number = .horizontalScrollPosition (listData.owner as DataGrid);

    the listData.rowIndex is 1-based (not zero) and is based on the visible line. So, if
    the first visible row is 12 and the second row on the screen has changed, then
    listData.rowIndex will be 2. To fix this, is subtracted 1 and firstRow is added.
    A similar thing is done for the columnIndex (what is zero-based).

    var int index = isEditedCell (listData.rowIndex - 1, listData.columnIndex + firstRow and firstCol);

    Determine the color of the cell

    If (index > = 0)
    {
    setStyle ("color", 0xff0000);
    }
    else {}
    setStyle ("color", 0x000000);
    }
    }
    }

    I hope this helps.

  • How to clear a selected line of the datagrid control in flex 4

    Hi friends,

    I have a datagrid and a button, delete once I've selected a line of datagrid, then click on Remove button medium it should remove the data grid.

    How to do this.please help.

    No matter what welcome suggession

    Thanks in advance,

    Vegas

    Hello

    For that you call the same function on click of a button. This button is outside your datagrid control.

    public void deleteItem(event:MouseEvent):void {}
    dgArrayCollection.removeItemAt (dg.selectedIndex);
    dgArrayCollection.refresh ();
    }

    Thank you and best regards,

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

    Kanchan Ladwani | [email protected] | www.infocepts.com

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

  • How to disable the elements (gray out) in the DataGrid control?

    Hello

    I need to implement a component custom for a selectable list with a maximum selected items.

    in other words, when the selected items reached the maximum, all unselected items will be gray outside.

    Now I am able to use the DataGrid control to display a selectable (by itemRenderer) "checkbox" to the first column, to let the user select the item.

    And the name of the list in the second column.

    But I can't find a way to grey out (disable) these no selected item when max is reached.

    Can someone give advice?

    Here is my code snippet:

    SelectableListView.mxml

    < mx:VBox ' xmlns:mx = ' http://www.Adobe.com/2006/MXML " " width ="100%" height = "100%" "visible ="true">

    "" " < mx:DataGrid id ="list_datagrid"dataProvider =" {} {this.stringList}"showHeaders ="false"

    "" "" editable = "false" "selectable ="true"verticalGridLines ="false"borderStyle ="No"alternatingItemColors = '[#F8F8F0, #FFFFFF]"

    "" "" left = "5" rowCount ="16" rowHeight = "20" height ="83" width = "100%"top ="0"doubleClickEnabled = "true" doubleClick ="onDoubleClick (event)" >

    < mx:columns >

    " < mx:DataGridColumn id ="listCheckBox_col"dataField ="selected"editable ="false".

    "itemRenderer ="ListRenderer"width ="18"headerText =" ' resizable ="false" draggable = "false"/ > "

    " < mx:DataGridColumn id ="listName_col"dataField ="name" / >

    < / mx:columns >

    < / mx:DataGrid >

    < / mx:VBox >

    ListRenderer.mxml

    < mx:Canvas ' xmlns:mx = ' http://www.Adobe.com/2006/MXML " " width ="100%" height = "60" > "

    < mx:Script >

              <! [CDATA]

    private function setInUse(): void

                   {

    _data.selected = listInUse.selected;

                   }

    []] >

    < / mx:Script >

    "" " < mx:CheckBox id ="listInUse"width ="18"height ="18"click ="setInUse()"selected =" _data.selected{}"/ > "

    < / mx:Canvas >

    What is listInUse insdie the itemRenderer? I'm not very clear on how you use

    it. However, there are 2 ways to do this. Do not know if data.selected can be used

    to toggle the itemrenderer. I'll so guess not. Have a bindable extra

    "enabled" in your model of dataProvider property. Thus, when you reach the maximum of

    selected items through the collection and defined the set of the activated

    as a result. The enabled property of the renderer is linked to active so model

    It should be updated accordingly. The other way is to bind the license of the

    rendering engine on the selected. But as I said I don't know how your code works...

    HTH,

    C

  • How to populate a datagrid control?

    [Flex framework 3.0]

    How to fill a DataGrid using data to a sqlite database. In this case, what can be the dataProvider. I have to define bindable?

    Location:

    I have an AIR application that fills a SQLite database. The AIR App has a DataGrid. The content of the database must be in the datagrid control. There is a button that fills the database if you click. Accordingly the view IE the datagrid needs to update. Do I need to query the database using the SELECT command each time?

    My main question is to make the datagrid show the content of the database.

    Say the database has three columns.

    Help, please.

    Thank you.

    Good luck

  • Maybe Flex SDK bugs: visible converters element DataGrid control

    Hi all, I'm still a noob to flex, but this seems a little strange to me.

    I tried to hide a converter button in a DataGrid control, but he would just hide.  I was setting visible inside the mxml and also in the class that extends the buttonbut would just hide.  Then, I overloaded the property visible set/get back what was setting the property and found that inside the DataGridBase.as the setupColumnItemRenderer function sets still visible of the renderes to true.

    DataGridBase.as
    protected function setupColumnItemRenderer (c:DataGridColumn, contentHolder:ListBaseContentHolder,
    rowNum:int, colNum:int, uid:String, data: Object): IListItemRenderer
    {
    var listItems:Array = contentHolder.listItems;
    var point: IListItemRenderer;
    var rowData:DataGridListData;

    Item = listItems [rowNum] [colNum];
    If (! point | itemToUID (item.data)! = uid)
    || columnMap [item.name]! = c)
    {
    Item = createColumnItemRenderer (c, false, data);
    If (point == null)
    Returns a null value.
    If (item.parent! = contentHolder)
    contentHolder.addChild (DisplayObject (item));

    a space is used if there is no so text widgets get a default size
    columnMap [item.name] = c;
    If (listItems [rowNum] [colNum])
    addToFreeItemRenderers (listItems [rowNum] [colNum]);
    listItems [rowNum] [colNum] = item;
    }

    [Mat] left in the above block out because
    the element is without a doubt at this stage and still need
    its up-to-date information
    rowData = DataGridListData (makeListData (data, uid, rowNum, c.colNum, c));
    rowMap [item.name] = rowData;
    If (item is IDropInListItemRenderer)
    IDropInListItemRenderer (point) .listData = data? rowData: null;
    Item.Data = data;
    item.Visible = true;

    If (uid & & colNum == 0)
    contentHolder.visibleData [uid] = item;
    return item;
    }

    Why would he do that?  If it should not respect the visible property for the mxml rendering engine already set and not force it to true on init?

    Converters use the visible property to recycling.  Invisible rendering engines are not supported.  The attack detection logic he would find the cell, it belongs to the same if it were invisible.  You can set alpha = 0, but that does not block the attack detection logic.

    Why are you trying to hide a converter?

    Alex Harui

    Flex SDK Developer

    Adobe Systems Inc..

    Blog: http://blogs.adobe.com/aharui

  • Question about Drag and Drop using DataGrid controls

    I use two DataGrids, each has a different type of object so that you can imagine when you drag - move into the other it causes an error in the cause the objects are not the same.
    I already managed to do this work, on the dragDrop event, I stop the default behavior of the event by the preventDefault () method, this way I can convert manually one object in another and then add it to the target of DataGrid.
    The problem is that because I stopped the default behavior of the event that remains the target DataGrid highlighted all the time (focus is on that point), so I have to do after my manual conversion object is to restore the DataGrid control to its normal state, which is what would have made the event's default behavior.

    So any ideas how to do that? restore the DataGrid control in its normal state? or perhaps restore an event so that it can continue its default behavior?

    OK I have found, after calling the preventDefault method and make my own logic, you call the method of the DataGrid hideDropFeedback () and that will do the job

  • Using a DataGrid control to get a RemoteObject

    What I have is a compound of two components. A component is a datagrid control that contains a list of users in it. The other component is just a group of checkboxes.

    Do I have to be able to do is select a user in the DataGrid and the second part, do trigger a RemoteObject call and returns the data about the person I selected in the datagrid control. What I need to know, is how to move selected users ID value to the RemoteObject call? The ID of the selected user is contained in an object called SelUserInfo.UserCnt. This object is sent to the second component when something is selected in the data grid. So far, that's what I have my code...

    My RemoteObject call:
    < mx:RemoteObject id = "getUserSec" destination = "ColdFusion" source = "ISIF. WebServices.Flex.UserData"ShowBusyCursor ="true">
    < mx:method name = "getUserSecRoles" result = "getRolesHandler (event)" >
    < mx:arguments >
    {SelUserInfo.UserCnt} < UserCnt > < / UserCnt >
    < / mx:arguments >
    < / mx:method >
    < / mx:RemoteObject >

    My Manager for the RemoteObject call:
    [Bindable]
    private var userSecRoles:ArrayCollection;

    private void getRolesHandler(event:ResultEvent):void
    {
    userSecRoles = new collection ArrayCollection (event.result as Array);
    }


    My function which is called when a user is selected in the datagrid control:
    public void getUserRoles(): Sub
    {
    getUserSec.getUserSecRoles.send ();
    }

    The problem is that the userSecRoles is always null. Does anyone know if I call the Number correctly?

    Have an ordinary day...
    KomputerMan ~ |  :-)

    Problem was found to be in the order that things were called. I would call the datagrid listener when a user has been selected by using this code:

    [Bindable]
    private var selectedUser2:Object;

    private void userSelHandler2(event:KDL_SelEvent):void
    {
    selectedUser2 = event. KDL_SelObject;
    getUserSec.getUserSecRoles (selectedUser2.UserCnt);
    Roles2TempID.getUserRoles (); initialize checkboxes
    }

    GetUserSec.getUserSecRoles (selectedUser2.UserCnt); line call my RemoteObject that calls the following event handler, to the Office of receiver data in a table.

    [Bindable]
    private var myUserSecRoles:ArrayCollection;

    private void getRolesHandler(event:ResultEvent):void
    {
    myUserSecRoles = new collection ArrayCollection (event.result as Array);
    }

    Problem is that the Roles2TempID.getUserRoles (); line of my datagrid selected event would trigger before the RO call was finished. In this way, I had all the data when the model is being developed. To resolve this problem, I call the code to initialize my model after that my manager RO be finished like this:

    [Bindable]
    private var myUserSecRoles:ArrayCollection;

    private void getRolesHandler(event:ResultEvent):void
    {
    myUserSecRoles = new collection ArrayCollection (event.result as Array);
    Roles2TempID.getUserRoles (); initialize checkboxes
    }

    Now the data is passed to the template until the model itself is initialized. My guess is that I have to do it this way because of Flex how threads. You mind just a guess. But it works now!

    Have an ordinary day...
    KomputerMan ~ |  :-)

  • Conditional image outside of a DataGrid control

    So Joan was kind enough to help me to use the data in a DataGrid cell and conditionally display an image corresponding to cell data. That worked fine, but now I have another question.

    Completely outside the datacell, I have a list of properties that show values based on the selected row in the grid (a detail view she had). Here again, I have the same question, where I need to post 1 of 6 images based on the value of a variable to the object selected in the DataGrid control.

    In the previous example, the solution was to substitute the data method, but which will not work in this case because the element is not a DataGrid control that takes care of that. Any thoughts on how I should approach this?

    Thanks Peter. I have used this set up an event listener to monitor the DataGrid control and then change the image accordingly.

  • assignment of several providers of data to a datagrid control

    Hello

    Is there any way by which I can assign several data providers in a DataGrid? I need get the different 2 arraycollections data and assign the data to a datagrid control for a user to compare.

    -Isabelle

    The datagrid control cannot have as a dataprovider. You can combine collections into a single table before linking to your DataGrid.

  • Highlight a row in a datagrid control by using code

    Does anyone know how to highlight a row in an instance of the DataGrid control by using the code?

    Thanks in advance...

    Set the selectedIndex example.

  • DateFormatter and a DataGrid control

    Confuised a bit here. I have a DateFormatter function I want to work with a datagrid control. I can use this function in other areas of the model without any problem. I can't do it to format the data in the datagrid control. So far, that's what I have:

    the action script that calls the trainer.
    public void formatDate(date:Date):String
    {
    if(date!=)
    {
    Return KDLDateFormat.format (date);
    } else {}
    return ";
    }
    }

    <! - my format string - >
    < mx:DateFormatter id = "KDLDateFormat" formatString = "DD-MMM-YYYY" / >

    <!-the grid data itself. ->
    < mx:DataGrid id = "dependantGrid" width = "460" left = "10" top = "10" height = "155" dataProvider = "{myDepData_Obj}" >

    <!-the column I want formatted->
    < mx:DataGridColumn dataField = "Dep_DOB" headerText = "Date of birth" labelFunction = "{format ()}" / > "


    This is the error message I get when I try to run the data grid. By the way... If I take the labelfunction I get the correct datetimestamp value in the datagrid.

    ArgumentError: Error #1063: incompatibility of County of Argument on components::DepInfo / format (). 1 EXPECTED, got 2.
    at mx.controls.dataGridClasses::DataGridColumn/itemToLabel()
    at mx.controls::DataGrid/::setupRendererFromData()
    at mx.controls::DataGrid/mx.controls:DataGrid::commitProperties()
    at mx.core::UIComponent/validateProperties()
    at mx.managers::LayoutManager/::validateProperties()
    at mx.managers::LayoutManager/::doPhasedInstantiation()
    function / http://adobe.com/AS3/2006/builtin::apply()
    at mx.core::UIComponent/::callLaterDispatcher2()
    at mx.core::UIComponent/::callLaterDispatcher()

    I tried to use it instead of the column and it worked up to a point. I want the date in the format DD-MMM-YYYY and it gave me the DD/MM/YYYY, but it worked.

    < mx:DataGridColumn dataField = "Dep_DOB" headerText = "DOB1" >
    < mx:itemRenderer >
    < mx:Component >
    < mx:Text text = "{(data. Dep_DOB. GetMonth () + 1) + "/" + (data. Dep_DOB. GETDATE()) + ' / ' + data. Dep_DOB.getFullY ear()} "/ >"
    < / mx:Component >
    < / mx:itemRenderer >
    < / mx:DataGridColumn >


    Thanks in advance for the help!

    KomputerMan ~ |  :-)

    The problem is in the function labelfunction of dataGridColumn is referring, the signature is wrong. Function of a labelFunction should have this signature:

    labelFunction(item:Object,_column:DataGridColumn):String

    If yours will be like this:
    public void formatDate(item:Object,_column:DataGridColumn):String
    {
    {if(date!=)}
    Return KDLDateFormat.format (order of the day. Dep_DOB);
    }
    else {}
    return ";
    }
    }

    You must also remove the data from your DataGridColumn definition area, you cannot have a labelFunction and a dataField, cause both determine the content of the column, you must use only one. Finally if you use the labelFunction you do not use {} or (), just the name of the function. It should be like this:

    This should work, tell me if something goes wrong

Maybe you are looking for

  • JumpStart

    JumpStart tabs does not I INSTALLED A NEWER VERSION OF FIREFOX, AND NOW THE TABS ADD - JUMPSTART - YOU'RE NOTOF WORK. When I open a new tab, it is empty and it shows no label if same JumpStartI added them to the elements tacked.

  • My brother macbook crashes on since yesterday.

    As in hours even on the other, my laptop keeps restarting.  I don't know what is the cause.  After the restart, he asks if I want to report an error - what I do - and it shows me this: Anonymous UUID: F8F47CC0-440E-CB1B-A512-625609BBEBD4 Mon Mar 21 1

  • Anyone else having a problem with Spotlight and iOs 9?

    I have all the Spotlight options switched immediately, but ever since the last update of the firmware (9.2.1) more time when I search for an app, nothing comes... I have 'Suggestions' allowed to. I tried to turn it off and restart my iPhone 6 and re-

  • HP Deskjet 3845 setting

    I should know this, but forgot how to set a default print style (e.g. print quality on the Quick project ).   Can someone remind me, please?   (Memory loss age taking too much effect these days)!

  • Impossible to update windows__

    I'm unable to update windows. It will not update