Auto expand Spark Datagrid rowcount with dataprovider

I have problems with a datagrid used within a VGroup.

I put the datagrid view to display a line + the header with the requestedRowCount = - 1

who says it has auto extend if several lines are added.

When a filter is applied, I have reset the requestedRowCount number of rows + 1 (for header).

monitoring indicates that the code is running

However the datagrid lines never change.

Is it because I'm not using the properties correctly or because it's within a VGroup?

Any suggestion would be greatly appreciated... of the code snippets below...

SamlpeScreenshot.png

// Filter Rentals by Job
if (arrRentalsByJob.filterFunction == null) arrRentalsByJob.filterFunction = filterByJob;
trace('Rentals Done');
arrRentalsByJob.refresh();
if (arrRentalsByJob.length == 0) {
   trace('adjusting rentals to min - num rentals = ' + arrRentalsByJob.length.toString());
   // Set the DataGrid row count to the array length, plus one for the header.                    
   dgRentalSummary.requestedRowCount = 2;
} else {
   trace('adjusting rentals to handle num rentals = ' + arrRentalsByJob.length.toString());
   dgRentalSummary.requestedRowCount = arrRentalsByJob.length + 1;
}

dgRentalSummary.invalidateDisplayList();

<s:DataGrid id="dgRentalSummary" width="811" height="48" dataProvider="{arrRentalsByJob}" editable="false" requestedRowCount="-1" rowHeight="20">
<s:columns>
  <s:ArrayList>
    <s:GridColumn dataField="rentalCompany" headerText="Rental Company" width="230"></s:GridColumn>
    <s:GridColumn dataField="rentalEquipment" headerText="Rental Equipment" width="500"></s:GridColumn>
    <s:GridColumn dataField="rentalCost" headerText="Cost" labelFunction="displayHours"></s:GridColumn>
</s:ArrayList>
</s:columns>
</s:DataGrid>               

Found the problem - using the tip of a previous post.

Impossible to actually define a first 'height' for the DataGrid - and I don't need to set the number of lines when I filter.

So... it works...

// Filter Rentals by Job
if (arrRentalsByJob.filterFunction == null) arrRentalsByJob.filterFunction = filterByJob;
trace('Rentals Done');
arrRentalsByJob.refresh();if (arrRentalsByJob.length == 0) {   dgRentalSummary.requestedRowCount = 2;} else {   dgRentalSummary.requestedRowCount = arrRentalsByJob.length + 1;}dgRentalSummary.invalidateDisplayList();



  
    
    
    




Tags: Flex

Similar Questions

  • Question of selection with editable Spark DataGrid

    Hello world

    I'm evaluating new Spark DataGrid and I am having a very strange problem with the selection behavior in an editable instance.

    Here is my test application: http://www.playcalliope.com/flex/DataGridSelectionIssue.html (code here: https://gist.github.com/1129160)

    And here are the steps to reproduce the problem:

    1. Select the first cell in the upper left corner of the grid (the one with 'Gabriele');
    2. click it once more, the Editor appears;
    3. now, click on the cell just to the right (the one with "Genta").

    You should see that edition ends as he supposed to do, but the selection is placed on the third cell (the one with a 5 in it) on the one you clicked on. Play a bit with the grid, you will see that this is not the only case, but selection really behaves randomly.

    I use SDK 4.5.1.21328.

    I think that it is a very basic use case... I can't believe that this does not work, what don't get me?

    Thank you very much

    Gabriele Genta

    Message was edited to add the living example

    Your race in a bug known, https://bugs.adobe.com/jira/browse/SDK-30088.

    The bug will be fixed in the Mega version. To work around the bug, you can create a custom editor and delete the "dataGrid.validateNow ()"; call to DataGridEditor.save ().

    Here's how I modified your example to work around the bug:


    http://ns.Adobe.com/MXML/2009.
    xmlns:s = "library://ns.adobe.com/flex/spark".
    xmlns:MX = "library://ns.adobe.com/flex/mx".
    minWidth = "955" = "600" minHeight
    backgroundColor = "#E7E7E7."
    creationComplete = "application1_creationCompleteHandler (event)" > "
       
           
       

       
       
            Import mx.collections.XMLListCollection;
    Import mx.events.FlexEvent;
    protected function application1_creationCompleteHandler(event:FlexEvent):void
    {
    testGrid.dataProvider = new XMLListCollection (testData.item);
    }
    ]]>
       

       
       
           
               
                   
                        1
                        Gabriele
                        Genta
                        5
                        molto
                   

                   
                        10
                        Weill
                        Pallino
                        10
                        poco
                   

               

           

           
           
               
                   
                        Import mx.collections.ICollectionView;
    Import mx.collections.ISort;
                           
    public void save (): Boolean
    {
    If (! validate())

    Returns false;
                               
    newData:Object var = value;
    var property: String = column.dataField;
    Object: data var = data;
    var typeInfo:String = "";
    for each (var variable: XML in describeType (data) .variable)
    {
    If (property == [email protected] ())
    {
    typeInfo = [email protected] ();
    break;
    }
    }
                               
    If (typeInfo is "String")
    {
    If (!) (newData) is String))
    newData = newData.toString ();
    }
    ElseIf (typeInfo == 'As')
    {
    If (!) () newData is uint))
    newData = uint (newData);
    }
    ElseIf (typeInfo == 'int')
    {
    If (!) (newData) is int))
    newData = int (newData);
    }
    ElseIf (typeInfo == "Number")
    {
    If (!) (newData) is number))
    newData = Number (newData);
    }
    ElseIf (typeInfo == "Boolean")
    {
    If (!) (newData) is Boolean))
    {
    var strNewData:String = newData.toString ();
    If (strNewData)
    {
    newData = (strNewData.toLowerCase () == 'true')? true: false;
    }
    }
    }
                               
    If (property & data [property]! == newData)
    {
    If the data is sorted, disable sorting for published data.
    var sort: ISort = null;
    If (dataGrid.dataProvider ICollectionView)
    {
    var dataProvider:ICollectionView = ICollectionView (dataGrid.dataProvider);
    If (dataProvider.sort)
    {
    type = dataProvider.sort;
    dataProvider.sort = null;
    }
    }
                                   
    var oldData:Object = data [well];
    data [property] = newData;
    dataGrid.dataProvider.itemUpdated (data, property, oldData, newData);
                                   
    Restoration of the kind. The data will be not sorted due to this change.
    If (out)
    . Fate ICollectionView (dataGrid.dataProvider) = classification;
    }
                               
    Returns true;
    }
    ]]>
                                   
               
               
           
       
       
       
    Editable = "true" selectionMode = "single-cell".
    itemEditor = "{ClassFactory (MyDefaultEditor) new}" >
           
               
                   
                   
                   
                   
               

           

       

  • Play with the spark datagrid

    I play with the spark datagrid and I have a column implemented as follows:

    "< GridColumn width ="140"headerText ="Margin"headerText.editMode =" Margin (montage) "dataField ="margin"editable ="false"editable.editMode =" true "itemRenderer ="gridColumnRenderer">
    < / GridColumn >

    I would like that the rendering of the element to change color depending on the State of the outerDocuent, is it possible?

    I tried this but can't seem to the outerdocument

    <? XML version = "1.0" encoding = "utf-8"? >
    " < = xmlns:fx s:ItemRenderer ' 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:Label text = "{data .margin}" backgroundColor = "{outerDocument.currentState == 'editMode'? 0xffffff:0xdddddd}" / > "

    < / s:ItemRenderer >

    I believe that you should not use GridItemRenderer instead of ItemRenderer as base class for renderers in spark DataGrid.  It works if you change that?

  • Spark Combobox with dataprovider is empty

    There seems to be a bug when using a candle with an empty dataprovider combobox.  The idea is to have an empty combobox that adds all entries in the dataprovider for each group entered.  Attached is a simple project to demonstrate.  The first combobox has a dataprovider to the color 'Red', 'green', 'Blue' in it.  No matter what type in the box, whether it's an existing element or a new one, it displays in the label below.

    The second combobox has a dataprovider that is currently empty.  Anything by typing in the box and pressing on enter does absolutely nothing.  There is no way to get the value entered in the combobox control now.

    <?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" minWidth="955" minHeight="600">
     <fx:Declarations>
      <!-- Place non-visual elements (e.g., services, value objects) here -->
     </fx:Declarations>
     <s:Panel x="10" y="10" width="250" height="200" title="Combobox with dataprovider">
      <s:ComboBox x="10" y="10" width="228" id="cbFull">
       <s:dataProvider>
        <s:ArrayCollection>
         <fx:String>Red</fx:String>
         <fx:String>Green</fx:String>
         <fx:String>Blue</fx:String>
        </s:ArrayCollection>
       </s:dataProvider>
      </s:ComboBox>
      <s:Label x="7" y="37" text="Selected Item: "/>
      <s:Label x="94" y="37" text="{cbFull.selectedItem}"/>
     </s:Panel>
     <s:Panel x="268" y="10" width="250" height="200" title="Combobox with empty dataprovider">
      <s:ComboBox x="10" y="10" width="228" id="cbEmpty">
       <s:dataProvider>
        <s:ArrayCollection/>
       </s:dataProvider>
      </s:ComboBox>
      <s:Label x="15" y="41" text="Selected Item: "/>
      <s:Label x="102" y="41" text="{cbEmpty.selectedItem}"/>
     </s:Panel>
    </s:Application>

    Fill out a bug with your test case report.

  • Spark datagrid GridItemRenderer cannot access a property or method of a null object reference

    Hello

    I created a spark datagrid with a griditemrender, but when my application startup and the dataprovider is null and have not given.

    At the error

    "Cannot access a property or a method of a null object reference.

    When have given do not have problem

    I was used to the griditemrender:

    prepare method, creationComplete, updateComplete, and all have the same aplication error begins

    any idea of this error?

    +++ My itemrender +++

    <? XML version = "1.0" encoding = "utf-8"? >

    " < = xmlns:fx s:GridItemRenderer ' http://ns.Adobe.com/MXML/2009 "

    xmlns:s = "library://ns.adobe.com/flex/spark" >

    < fx:Script >

    <! [CDATA]

    override public function prepare(hasBeenRecycled:Boolean):void

    {

    valueDisplay.selected = data [column.dataField] as Boolean;

    }

    []] >

    < / fx:Script >

    < s:CheckBox id = "valueDisplay" / >

    < / s:GridItemRenderer >

    Maybe you can try a preliminary validation before the award of 'data '.

    Of

    valueDisplay.selected = data[column.dataField] as Boolean;
    

    TO:

    if(data)
    {
        valueDisplay.selected = data[column.dataField] as Boolean;
    }
    

    I would like to know if it works.

    Best regards

    Pablo Souza

  • Cannot see the data of the model within inline ItemRenderer in Spark DataGrid

    I'm having a problem displaying the model data in an ItemRenderer, online in a Spark DataGrid

    Here is the code for the DataGrid control

    < s:DataGrid id = "moduleDG" includeIn = "HomeRequired" x = "20" y = "116" width = "764" height = "404".

    " click =" DGchangeHandler (event) "dataProvider =" {model.items} ">

    < s:columns >

    < s:ArrayList >

    < s:GridColumn id = "myModuleName" dataField = "moduleName" headerText = "{model.ui_nameColumn_str}" / > "

    < s:GridColumn id = "myEnterColumn" dataField = headerText = "{model.ui_actionColumn_str"launchActionText"}" >

    < s:itemRenderer >

    < fx:Component >

    < s:GridItemRenderer >

    < s:Button label = "{parentDocument.model.ui_nameColumn_str}" / > "

    < / s:GridItemRenderer >

    < / fx:Component >

    < / s:itemRenderer >

    < / s:GridColumn >

    < / s:ArrayList >

    < / s:columns >

    < / s:DataGrid >

    In the "inline" without the parentDocument reference ItemRendered, I get an 1120: access of undefined property error model. If I use outerDocument I get 1178: any attempt to access the property model inaccessible through a reference with static type error. I don't know what I should use here...

    The next column has no difficulty to display the property of model.ui_nameColumn_str - I understand the issue around scope and view the correct instance, I don't know how to get the model of the inline ItemRenderer. (We use simplemvc)

    Thank you

    Model must be a public variable, then outerDocument should work.

  • Panels don't Auto expand

    The last couple days, I noticed that my panels I set to auto expand will do no more. In order to use the panels, I have to develop all the panels in the column or to work in 'demand' that I do not do. I am running OSX 10.10 with the latest version of Photoshop. Help, please. Does anyone else have this problem?

    I would try to reset the preferences of photoshop by pressing and holding down the Command + Option + shift keys when you start photoshop.

    Keep possession of the keys down until you get a dialog box asking if you want to delete the file from photoshop settings

    Press Yes

  • Spark Datagrid columnheader click

    Hello!

    With the next Eventlistener I can detect a click on the Spark Datagrid header.

    dg.sortableColumns = false;
    dg.columnHeaderGroup.addEventListener (MouseEvent.CLICK, headerClickListener);
    ……………..
    Event handler header
    private void headerClickListener(event:MouseEvent):void {}
    Alert.Show ("something");

    But how do I detect the current column of the user clicked Headeritem?

    In my view a Build-In Header-Click-event and a Build-In Columnlocking is a "Must Have" of a professional Datagrid.

    Will there be a Flexupdate with a Datagrid improved spark in next time?

    Greetings

    Uwe

    Instead of listening for the GridEvent.GRID_CLICK event. The GridEvent will be the index of the column in it. We return all the events of the mouse on the DataGrid as GridEvents.

    -Kevin

  • Bind a column to two fields in the spark DataGrid

    Hello

    IMED a spark datagrid that uses a GridItemRenderer with a RichText label display.

    the RichText column should display two or more fields of colors and sizes of diffrenet.

    How can I bind the column in two or more fields?

    any help would be great.

    Try changing

    lblData.text = data [column.dataField]

    TO

    lblData.textFlow = TextFlowUtil.importFromXML (XML (column.dataField));

    and also change the label function to wrap the back while

    While he will evaluate to valid XML

    HTH;

    Amy

  • Questions about Spark DataGrid (header font Styles, gradient header)

    Just starting in 4.5 SDK and just a little confused on the Spark DataGrid.

    (1) to set the font style for only the head, but do not see these properties in the designer... as they seem to apply to each part of the data grid.

    (2) want to set a linear gradient in the header using two specific colors, alphas, and ratios.  Don't know where to put it now.

    I think that's all for now.  What I did with it up to now, I love... but obviously not as many as MX DataGrid user documentation.

    Thanks in advance!

    Bill

    You can do a column header converters by setting the property of the column. But if you want to exchange all the headers, the header is rendered must be specified in the skin. A trick you can do is subclass the Datagridskin and replace the declaration of 'his '. It also works with other parts of the skin.

    
    
    
        
    
            
            
                
            
    
        
    
    
    

    -Kevin

  • ETA for Spark DataGrid / AdvancedDataGrid?

    I just downloaded the new Flash Builder 4 and came to the disappointing conclusion that there are no equivalents for controls DataGrid and AdvancedDataGrid Spark.  There seems to be several orders, which do not have equivalents of the spark.  I stumbled on Alex's blog post where he mentions the lack of time for the parity of 100% with MX.  However, it would be nice if Adobe could release a timeline of when parity with MX controls is achieved.

    Hello-

    In Flex 4, we introduced a new component and skinning architecture called Spark. We have built many components, called Spark components, which use this new component model, but has not reached parity with regard with the equivalents of spark for * all * given available items in the component MX (Flex 3 and earlier versions). Especially missing are spark versions of components DataGrid, AdvancedDataGrid and trees. In places where the equivalent of the spark is not available, it is 100% ok to use the MX control as spark content can contain content MX and vice versa.

    Who spark to reach parity with the MX is a huge focus for our next version of Flex. In fact, we are current active development works on versions of the spark DataGrid, AdvancedDataGrid and trees. Because we develop out in the open, you can see downloading development builds nightly Flex 4 and looking at the feature specs posted on the Open source Adobe (http://opensource.adobe.com/wiki/display/flexsdk/Flex+4) site.

    In addition, many of the teams of Engineering (such as Alex Harui), but also members of the community have displayed prototypes of components created by using spark that are not currently part of the native Spark delivered with Flex 4 components. If you do not use the version MX controls that do not have equivalents of spark, I encourage people to read the posted samples and increase them as they see fit.

    Hope this helps,

    Deepa Subramaniam

    Flex SDK Product Manager

  • 'For' loop with a different number of iterations. Second, the auto-indexation of the tables with different sizes is done. It can affect the performance of the Vi?

    Hello

    I have a loop 'for' which can take different number of iterations according to the number of measures that the user wants to do.

    Inside this loop, I'm auto-indexation four different 1 d arrays. This means that the size of the tables will be different in the different phases of the execution of the program (the size will equal the number of measures).

    My question is: the auto-indexation of the tables with different sizes will affect the performance of the program? I think it slows down my Vi...

    Thank you very much.

    My first thought is that the compiler to the LabVIEW actually removes the Matlab node because the outputs are not used.  Once you son upward, LabVIEW must then call Matlab and wait for it to run.  I know from experience, the call of Matlab to run the script is SLOW.  I also recommend to do the math in native LabVIEW.

  • How can I prevent the Panel 'Links' auto expanding whenever I select (eg. to move) a placed image?

    How can I prevent the Panel 'Links' auto expanding whenever I select (eg. to move) a picture - it's really annoying!

    Yes I hate it too.

    you have to hide the link info down. Click on the small triangle at the bottom of the palette. for some reason, adobe couldn't figure out how to make a text wrapping.

  • Change the color of the selected TEXT to line Spark DataGrid

    Hello

    Does anyone know of a way to change the color of the text of the selected line in a spark DataGrid? I am able to change the color of flipping, etc, but can't seem to find a way to change the color of the text.

    Let's say the default value is black for all lines. I want to make the color of the text of the line selected, for example, red. Ideas through CSS or Skinning?

    Thank you

    Victor

    I think you need to create a custom item Renderer.

    If you use FlashBuilder, just ask to a default one for you and look at the code.

    I wil put a code here, but everything will be guess I can't check my answer just now. So what I write may be incorrect. I'll look again to change you

    NOTE PLEASE. WHAT CAN BE WRONG. I JUST TRIED TO REMEMBER OFF THE TOP OF MY HEAD!

    http://ns.Adobe.com/MXML/2009.

    xmlns:s = "library://ns.adobe.com/flex/spark".

    xmlns:MX = "library://ns.adobe.com/flex/mx".

    clipAndEnableScrolling = 'true '.

    override public function discard(willBeRecycled:Boolean):void

    {

    Super.Discard (willBeRecycled);

    }

    override public function prepare(hasBeenRecycled:Boolean):void

    {

    if(Data && Selected)

    {

    lblData.setStyle ("color", 0xffff00);

    Search for the 'format' function

    If (column.labelFunction! = null)

    {

    lblData.text = column.labelFunction (data, column);

    }

    on the other

    {

    lblData.text = data [column.dataField];

    }

    }

    Super.Prepare (hasBeenRecycled);

    }

    ]]>

  • Spark DataGrid - how to change the colors itemRenderer dynamically in code

    I need to dynamically change some attributes of my spark DataGrid at runtime, such as the header colors, the colors of the column and whether to show the lines of lines/columns in grids.  I've seen hundreds of examples to do, but they are all hard coded.  For example; by creating a custom "BlueGridHeaderRenderer" and the color is hardcoded to blue.

    What I need to do, is to change the color when running via ActionScript.  For example; by creating a MyHeaderRenderer and be able to dynamically set the color in the code through function or property.

    It looks like a pretty simple request... but I've been hitting my head against the wall on this one.  Is it still possible?  If so, can you share some examples of code, or at least point me in a direction?

    Thank you!

    Look at IGridItemRenderer.prepare ().

    Carol

Maybe you are looking for