WordWrap in DataGrid

Hello

I want to implement the DataGrid control that should: -.

1 wordwrap text inside the cell (without horizontal scroll bars) (note skill5 in table)

2. place a no. when vertical scroll bar. entries exceeds 5

3. hide the column headers

I have the following initial code: -.

< mx:Script >
<! [CDATA]
Import mx.collections.ArrayCollection;

[Bindable]
public var MySkills: collection ArrayCollection = new ArrayCollection ([] collection
{label: "skill1', MySkill: 'SAP', the Professor: 'Expert'},
{label: "skill2", MySkill: 'JAVA', the Professor: 'Expert'},
{label: "skill3", MySkill: ".NET", the Professor: 'DÉBUTANTE'},
{label: "skill4', MySkill: 'ORACLE', the Professor: 'DÉBUTANTE'},
{label: "skill5", MySkill: "WEB Agency.4 ABCDEFGH', the Professor: 'EXPERT'},
{label: "competence6", MySkill: "Adobe Flex", the Professor: 'DÉBUTANTE'}
]);
[]] >
< / mx:Script >

< mx:DataGrid id = "myGrid" dataProvider = "{MySkills}" >
< mx:columns >
< mx:DataGridColumn dataField = "MySkill" / >
< mx:DataGridColumn dataField = 'Teacher' / >
< / mx:columns >
< / mx:DataGrid >

Please guide/help.

Thank you and best regards,

Amey

Try this code

place this code in the header of the datagrid control:

1.ROWCOUNT "{MySkills.Length}" "

If you want to set 5 statically means use rowcount = "5" in the case otherwise don't use rowcount nd on verticalscrollpolicy = "true";

2.showHeader 'true '.

3.verticalScrollPolicy = 'true '.


            
                
                
            

      

Tags: Flex

Similar Questions

  • Setting cell values in the DataGrid control

    I have a request to a custom component called DataEntryDataGrid (which is a subclass of mx:DataGrid) I started on this blog: http://blogs.Adobe.com/aharui/2008/03/custom_arraycollections_adding.html

    The component works fine, but in this particular datagrid, I need special features.   After the first line of data is entered in the tabs of the user in the following line, I need the first and second columns to be filled based on the values of the previous row and then I need to automatically focus on the cell in the third column.  While the first and second columns must be always editable, they will be largely repetitive, and it would help if users did not have to enter the same numbers over and over again.  The first column of the new row should be the same value as the first column in the last row and the second column of the new row should be (value of the last row + 1). Example:

    DataGrid:
    
    | Slide No. | Specimen No. | Age | Weight | Length |
    |    1      |     1        |  5  |  65    |  40    |  <- This row is manually entered, just text inputs
    |    1*     |     2*       |  #  |        |        |
    
    * = values set programatically, these cells should still be focusable and editable
    # = this is where the focus should be
    

    The problem I have is that when I tab in the next line, the first value in the column don't prepare you.  The second column gets the value correct and properly displayed and emphasis is placed in the correct cell (the third column), but the first column remains empty.  I don't know why that is.  If I put a breakpoint in the code in the function focusNewRow() (which is called in the event of the dataGrid "itemFocusIn") (first column) "slideNo" value is set to the correct value, but after the 'focusNewRow' work finishes, a dataProvider trace [the current line] .slideNo shows the value is empty.  Non-null, just empty.  Traces of all other columns indicate the correct values.  Anyone have any ideas?  Here is the code for my main application:

    <?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" xmlns:components="components.*">
      <fx:Script>
        <![CDATA[
          import mx.controls.DataGrid;
          import mx.events.DataGridEvent;
          
          public function traceSlideNo():void {
            var i:int;
            var g:Object = myDataGrid.dataProvider;
            for(i = 0; i < g.length -1; i++) {
              trace("sl: " + g[i].slideNo + ", sp: " + g[i].specimenNo + ", age: " + g[i].age);
            }
          }
          
          public function focusNewRow(e:DataGridEvent):void {
            if(e.currentTarget.dataProvider.length > 0 && e.rowIndex != 0 && e.columnIndex == 0) {
              var dg:DataGrid = e.currentTarget as DataGrid;
              var lastItem:Object = dg.dataProvider[e.rowIndex - 1];
              var targetItem:Object = dg.dataProvider[e.rowIndex];
              if(targetItem.specimenNo == "") {
                var focusCell:Object = new Object();
                focusCell.rowIndex = e.rowIndex;
                focusCell.columnIndex = 2;
                dg.editedItemPosition = focusCell;
                
                targetItem.slideNo = int(lastItem.slideNo);
                targetItem.specimenNo = int(lastItem.specimenNo) + 1;
                
                callLater(dg.dataProvider.refresh);
              }    
            }
          }
        ]]>
      </fx:Script>
      
      <components:DataEntryDataGrid x="10" y="10" width="450" id="myDataGrid" itemFocusIn="focusNewRow(event)"
                      editable="true" rowHeight="25" variableRowHeight="false">
        <components:columns>
          <mx:DataGridColumn headerText="Slide No." dataField="slideNo" editable="true"/>
          <mx:DataGridColumn headerText="Specimen No." dataField="specimenNo" editable="true"/>
          <mx:DataGridColumn headerText="Age" dataField="age" editable="true"/>
          <mx:DataGridColumn headerText="Weight" dataField="weight" editable="true"/>
          <mx:DataGridColumn headerText="Length" dataField="length" editable="true"/>
        </components:columns>
      </components:DataEntryDataGrid>
      <s:Button x="10" y="195" label="Trace Slide Numbers" click="traceSlideNo()"/>
    </s:Application>
    

    And here is the custom component, DataEntryDataGrid, just for reference (place in the "components" package in this example):

    <?xml version="1.0" encoding="utf-8"?>
    <mx:DataGrid xmlns:fx="http://ns.adobe.com/mxml/2009" 
           xmlns:s="library://ns.adobe.com/flex/spark" 
           xmlns:mx="library://ns.adobe.com/flex/mx" initialize="init(event)"
           editable="true" wordWrap="true" variableRowHeight="true">
      <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
      </fx:Declarations>
      
      
      
      <fx:Script>
        <![CDATA[
          import components.NewEntryArrayCollection;
          
          import mx.controls.Alert;
          import mx.controls.dataGridClasses.DataGridColumn;
          import mx.events.DataGridEvent;
          import mx.events.DataGridEventReason;
          import mx.events.FlexEvent;
          import mx.utils.ObjectUtil;
          
          private var arr:Array = [];
          private var ac:NewEntryArrayCollection;
          private var dg:DataGrid;
          
          public var enableDeleteColumn:Boolean;
          
          private function generateObject():Object
          {
            // Returns a new object to the datagrid with blank entries for all columns
            var obj:Object = new Object();
            for each(var item:Object in this.columns) {
              var df:String = item.dataField.toString();
              obj[df] = "";
            }
            return obj;
          }
          
          private function isObjectEmpty(obj:Object):Boolean
          {
            // Checks to see if the current row is empty
            var hits:int = 0;
            
            for each(var item:Object in this.columns) {
              var df:String = item.dataField.toString();
              if(obj[df] != "" || obj[df] !== null) {
                hits++;
              }
            }
            if(hits > 0) {
              return false;
            }
            return true;
          }      
          
          private function init(event:FlexEvent):void
          {
            dg = this;                // Reference to the DataEntryDataGrid
            ac = new NewEntryArrayCollection(arr);  // DataProvider for this DataEntryDataGrid
            ac.factoryFunction = generateObject;
            ac.emptyTestFunction = isObjectEmpty;        
            dg.dataProvider = ac;
            
            // Renderer for the DELETE column and Delete Button Item Renderer
            if(enableDeleteColumn == true){
              var cols:Array = dg.columns;
              var delColumn:DataGridColumn = new DataGridColumn("del");
              delColumn.editable = false;
              delColumn.width = 35;
              delColumn.headerText = "DEL";
              delColumn.dataField = "delete";
              delColumn.itemRenderer = new ClassFactory(DeleteButton);
              cols.push(delColumn);
              dg.columns = cols;
              dg.addEventListener("deleteRow",deleteClickAccept);
            }
          }
          
          private function deleteClickAccept(event:Event):void { // Handles deletion of rows based on event dispatched from DeleteButton.mxml
            dg = this;
            ac = dg.dataProvider as NewEntryArrayCollection;
            if(dg.selectedIndex != ac.length - 1) {
              ac.removeItemAt(dg.selectedIndex);
              ac.refresh();
            }
          }
    
        ]]>
      </fx:Script>
      
    </mx:DataGrid>
    

    In addition, the NewEntryArrayCollection.as file that is referenced by the component custom.  This is true also in the package "components":

    package components 
    {
      import mx.collections.ArrayCollection;
      
      public class NewEntryArrayCollection extends ArrayCollection
      {
        private var newEntry:Object;
        
        // callback to generate a new entry
        public var factoryFunction:Function;
        
        // callback to test if an entry is empty and should be deleted
        public var emptyTestFunction:Function;
        
        public function NewEntryArrayCollection(source:Array)
        {
          super(source);
        }
        
        override public function getItemAt(index:int, prefetch:int=0):Object
        {
          if (index < 0 || index >= length)
            throw new RangeError("invalid index", index);
          
          if (index < super.length)
            return super.getItemAt(index, prefetch);
          
          if (!newEntry)
            newEntry = factoryFunction();
          return newEntry;
        }
        
        override public function get length():int
        {
          return super.length + 1;
        }
        
        override public function itemUpdated(item:Object, property:Object = null, 
                           oldValue:Object = null, 
                           newValue:Object = null):void
        {
          super.itemUpdated(item, property, oldValue, newValue);
          if (item != newEntry)
          {
            if (emptyTestFunction != null)
            {
              if (emptyTestFunction(item))
              {
                removeItemAt(getItemIndex(item));
              }
            }
          }
          else
          {
            if (emptyTestFunction != null)
            {
              if (!emptyTestFunction(item))
              {
                newEntry = null;
                addItemAt(item, length - 1);
              }
            }
          }
        }
        
      }
    
    }
    

    Sorry for the length of this post, but I hate to see people post without including enough information to solve the problem.  If there is nothing, I have left out, made me know.

    I think that in the NewEntryArrayCollection, I would wire up to generate a

    populated point instead of where you are right now.

  • MYSQL text field appears correctly in Datagrid

    Hello

    I have a datagrid which gets its data from a webservice. The result is a text field in the mysql database which is something like this:

    Hello

    Some text here. Some more text.

    Thank you

    When that field is displayed in the DataGridColumn, only the first line is to say 'Hi', gets displayed. I tried to set the property wordwrap and variableRowHeight true. but dsnt work. I even put the ItemEditor to mx.controls.Text and mx.controls.TextArea. Still nothing. No idea how to get all the text to display in the column.

    Still one thing to note is that I have the itemRenderer for this datagrid to mx.controls.Label column, so that if the textcontent is greater than the content of the cell, datagrid will truncate the text and display a ToolTip. So, I expected the ToolTip is displayed in this case, but it dsnt.

    I confirmed that the webservice response contains the paragraph of text... so it only means that things are going wrong during the time display...

    Help, please!

    Because you used the label as driving force of rendering you will get a... When the width of text > width of the label. But here you don't him have not found because the width of the text could not be greater than the width of the label. The text in question here is a multiline text. Label will show only single line. And the longer your data line is also less than the width of the label. That's why not. You can check this by giving a long line of your data and it will show a... and the ToolTip (if you use the label as itemrenderer).

    The default item converter will display the multiline text. So no need to specify any itemRenderer.You may have variableRowHeight set to true. There is no need to use the itemEditor to get what you are looking for. Yet one thing, an editor of point will only work if you set the property editable DataGrid and the itemeditor usage column is set to true.

    Hope that I have answered your question

  • How can I wordwrap a grid column header

    I tried the word property of packaging and nothing happened.  Obviously, something else has to happen to make this work.

    What is it?

    If the label is inside a datagrid control, you must specify the property of the Datagrid to true "variableRowHeight' and

    the datagridcolumn wordWrap = "true"

  • DataGrid Sorting, new high page elements

    Hi all

    I have the following datagrid

    < mx:DataGrid id = "chatDG" width = "60%" height = "100%" x = "0" y = "0" fontSize = "25" variableRowHeight = "true" >
    < mx:columns >
    < mx:DataGridColumn headerText = "" dataField = "message" wordWrap = "true" / > "
    < / mx:columns >
    < / mx:DataGrid >

    That pulls information from a mysql database using the below php script

    <? PHP
    $hostname_conn = "localhost";
    $username_conn = 'u ';
    $password_conn = "pw";

    $conn = mysql_connect ($hostname_conn, $username_conn, $password_conn);

    @mysql_select_db ("DB");

    $query = "SELECT * FROM THE CAT;

    $result = mysql_query ($query);

    While ($Row = mysql_fetch_array ($result))
    {
    echo "< cat > < message >. $row ['message']. "" < / message > < / cat > \n ";
    }

    ? >

    and the following functions from flex

    private void GetAllMessage (): void
    {
    getMessage.send ();
    setTimeout (GetAllMessage, 1000);
    }
    private void viewMessageResult(evt:ResultEvent):void
    {
    chatDG.dataProvider = evt.result.chat;
    }
    []] >
    < / mx:Script >

    < mx:HTTPService id = "getMessage" url = "getMessage.php" method = "POST" result ="viewMessageResult (event)" > "
    < mx:request xmlns = "" >
    < data > {dataDump} < / data >
    < / mx:request >
    < / mx:HTTPService >

    As it is at the moment of the new questions that are submitted to the database is displayed in the bottom of the datagrid, is there a simple and effective way to replace it?  Then this new message, go to the top?

    I have looked but can't seem to make it work =]

    Where would understand the statement you mentioned?

    "SELECT * CHAT ORDER BY Desc messageID.

    If you could help I would be very grateful

    assuming that your database now looks like this:

    you will just place it where was your original query statement:

    ".$row['message']."\n";
        }
    
    ?>
    
  • How can we change an image programmatically in the DataGrid cell

    I have a DataGrid that contains a status icon. I was able to get the initial to display in the DataGrid control status icon. But I'm unable to update the computer. Basically, I need to update the image of a selected line with a "assets/processing.png", ' assets/success.png' or ' assets/failure.png' image. I can't seem to be able to find a way to access the image in the cell need to update/replace it. I tried to give him a property from my collection ArrayCollection data provider, but it does not work. I also tried some how to get a reference to the original image, so it can be replaced, but can not understand how to do such. Here is the code for my DataGrid. I'll be very grateful for any help in this. (I'm relatively new on Flex/ActionScript, but a developer experienced otherwise).

    <mx:DataGrid id="myDataGrid" left="0" top="0" bottom="0" right="0"
                         allowMultipleSelection="true" verticalScrollPolicy="on"
                         draggableColumns="false" resizableColumns="false" sortableColumns="false"
                         dataProvider="{myArrayCollection}">
                <mx:columns>
                    <mx:DataGridColumn headerText="Name" dataField="name" wordWrap="true" />
                    <mx:DataGridColumn headerText="Status" dataField="status" width="75" textAlign="center">
                        <mx:itemRenderer>
                            <mx:Component id="statusComponent">
                                <mx:HBox id="imageBox" width="100%" height="100%" horizontalAlign="center">
                                    <mx:Image id="statusImage" source="@Embed('assets/pending.png')" width="16" height="16"  />
                                </mx:HBox>
                            </mx:Component>
                        </mx:itemRenderer>
                    </mx:DataGridColumn>
                </mx:columns>
            </mx:DataGrid>
    

    The image must be a property of the arrayCollection collection.  You can either save the image url as a property of type string, or if you must nest, then you can create an actionscript for each image object in a script (private var image1:Image = Image(); image1.source=@embed...)

    Then, in the code that processes the event that causes the image must change, replace the image property of the collection arrayCollection member (s) concerned. Then, at the end of the code for the event, trigger the DataGrid to update using the method myDataGrid.invalidateList ();

    Mark

  • Error #1009 by clicking on datagrid scrollbar

    Hello

    I'm getting the TypeError: Error #1009: cannot access a property or method of a null object reference.
    to SampleDragDropDataGrid / initDGAlternateALGYBenefits () [C:\workspace\flex3Samples\src\Sample DragDropDataGrid.mxml:244]
    to SampleDragDropDataGrid / __dgCurrentBenefits_click () [C:\workspace\flex3Samples\src\SampleDr agDropDataGrid.mxml:600]

    I want a user to click on a row of data in a datagrid display more records associated with the selected item in an another datagrid control. I wanted the user to be able to drag the new record in the datagrid control that displays the original list. The error appears when you click the scroll bar in the DataGrid, but works very well when you click on one of the elements.

    Here is the code for the datagrid control:
    < mx:DataGrid id = "dgcurrentRecords" x = "10" y = "36" width = "400" height = "200".
    creationComplete = "{initDGcurrentRecords ()}" "

    dataProvider = "{currentRecords}".
    Click = "initDGalternateRecords ()" "
    dropEnabled = "true".
    dragEnabled = "true".
    dragMoveEnabled = "true".
    number of lines = "10".
    variableRowHeight = "true".
    toolTip = "select new record by dragging the selected Alternative record" cornerRadius backgroundAlpha = "4" = ".1" >
    < mx:columns >
    < mx:DataGridColumn headerText = "Category" dataField = "category".
    textAlign = "center" width = "70" / >
    < mx:DataGridColumn headerText = "#" dataField = "number".
    textAlign = "center" width = "40" / >
    < mx:DataGridColumn headerText = "Description".
    dataField = "description" width = "290".
    wordWrap = "true" / >
    < / mx:columns >
    < / mx:DataGrid >

    When you click anywhere in the data grid, I call the initDGAlternateALGYBenefits() function, which, according to the file clicked, will display the replacement data in the data grid right.
    private function initDGalternateRecords (): void
    {
    alternateRecords = new ArrayCollection();

    If (dgcurrentRecords.selectedItem.category == "")
    {
    vboxAlternateRecords.visible = false;
    }

    If (dgcurrentRecords.selectedItem.category is "NATHALIE")
    {
    vboxAlternateRecords.visible = true;
    alternateRecords.addItem ({category: "NATHALIE", number: "4",})
    ({Description: '$3 INJECTIONS'});
    alternateRecords.addItem ({category: "NATHALIE", number: "5",})
    ({Description: '$5 INJECTIONS'});
    }

    }

    I'd appreciate any help or if someone could point me in a direction where is a solution for this I would be very happy. Also, can someone tell me why I'm not able to dragandMove points of the data grid on the right to the data grid on the left? (dragMove is enabled).

    Thank you!

    Errol
    Example is here: http://ekmstudios.com/flexSamples/FlexSamples/bin-release/FlexSamples.html

    View code here: http://ekmstudios.com/flexSamples/FlexSamples/bin-release/srcview/index.html

    Vygo,

    Ah, itemClick. Thank you! Who did. I had the change event here initially for other thing and neglected to remove it. Is not necessary for this.
    Thanks again,

    Errol

  • DataGrid data binding problems

    I'm trying to create a DataGrid control in code and fill it with information. The final product, that I am creating is a form that displays the files you have selected after the navigation of your computer. I intend to place the FileReferenceList table informaiton which will become the dataProvider of the DataGrid.

    Would be it someone please let me know what I am doing wrong, or provide a link to an excellent resource on how to create and use DataGrids with Actionscript 3?

    I get the following error;

    "ArgumentError: Error #1063: incompatibility of County Argument...". »

    This error occurs during the process of binding the dataProvider method.

    Here is an example of the relevant code, I try to use;

    var _dgFiles:DataGrid = new DataGrid();
    _dgFiles.allowDragSelection = false;
    _dgFiles.AllowMultipleSelection = true;
    _dgFiles.resizableColumns = false;
    _dgFiles.sortableColumns = false;
    _dgFiles.percentWidth = 100;
    _dgFiles.percentHeight = 100;

    var aColumns:Array = _dgFiles.columns;

    var dgcIcon:DataGridColumn = new DataGridColumn();
    var dgcName:DataGridColumn = new DataGridColumn();
    var dgcSize:DataGridColumn = new DataGridColumn();
    var dgcFile:DataGridColumn = new DataGridColumn();

    dgcIcon.headerText = "";
    dgcIcon.dataField = "icon";
    dgcIcon.width = 26;
    dgcIcon.editable = false;
    dgcIcon.resizable = true;
    dgcIcon.visible = false;

    dgcName.headerText = 'file ';
    dgcName.dataField = "name";
    dgcName.editable = false;
    dgcName.resizable = true;

    dgcSize.headerText = "size";
    dgcSize.dataField = "size";
    dgcSize.width = 50;
    dgcSize.editable = false;

    dgcFile.headerText = "Data";
    dgcFile.dataField = "data";
    dgcFile.wordWrap = false;
    dgcFile.editable = false;
    dgcFile.visible = false;

    aColumns.push (dgcIcon);
    aColumns.push (dgcName);
    aColumns.push (dgcSize);
    aColumns.push (dgcFile);
    _dgFiles.columns = aColumns;

    addChild (_dgFiles);

    var a1:Array = new Array({icon:"*.jpg",name:"FileName1.jpg",size:10002,data:"TEST1"});)
    var a2:Array = new Array({icon:"*.jpg",name:"FileName2.jpg",size:10002,data:"TEST2"});)
    var a: Array = new Array();
    a.push (a1);
    a.push (a2);
    _dgFiles.DataProvider = a;

    That is, it fails. I think that my test table 'a' is not correct. How can I provide the correct information for the
    DataGrid so that it works?

    I think that there is a mistake where you are combining tables:

    a.push (a1);
    a.push (a2);

    actually creates a table to 2 dimensions, instead of concatenated in a single table. Is that what you wanted?

    For a datagrid control, you want a table/collection ArrayCollection of objects.

    I copied and pasted your code and changed the table to this part:

    var data: Array = new Array)
    {icon: "*.jpg", name: "FileName1.jpg", size: 10002, data: 'TEST1'},
    {icon: "*.jpg", name: "FileName2.jpg", size: 10002, data: 'TEST2'}
    );

    _dgFiles.DataProvider = new ArrayCollection (data);

    And he works as (I think) you want.

  • Text box has no wordwrap on developer eddition?

    I use the FF deveooper (such as the debugger FYI) edition but I have a problem now.

    Since the upgrade today, text boxes in some of the forums I visit is no longer have wordwrap in them. I checked the settings and can not find them. I also searched the topic: config and not got anywhere. I saw two var there.

    plain_text_wrap_long_lines (is true)
    view_source_wrap_long_lines (is true).

    Anyone got a clue?

    You can click on the right than the text box and open the Inspector to see if there is a such envelope this rule and if not add it, and possibly use the userContent.css file to define such a rule.

    @-moz-document domain(<domain>){ textarea { white-space:pre-wrap!important; word-wrap:break-word!important; } }
  • DataGrid tool disabled in the Toolbox of Visual Studio 2012

    Hi all

    I recently downloaded Visual Studio 2012 and developing an MFC dialogue-based application. Facing a problem very strange pf being able to use the "DataGrid" tool on the Windows dialog box. The tools 'Datagrid' is disabled even though the same choose thru "choose the Item' in the menu the same watch TooBox disabled. Can someone why the same problem occurred. I use Visual Studio Professional 2102.
    BR / / Vidit

    Hello

    Visual Studio is not supported in these forums. I suggest you instead please post your question in the relevant forum to Microsoft Developer Network (MSDN) this product:

    http://social.msdn.microsoft.com/Forums/en-US/category/visualstudio .

    Thank you.    :)

  • Design DataGrid with VB 6.0 source code

    I use DataGrid with VB 6 and I want my design grid? How ti source code to this topic...

    Thank you

    Hello

    The question you have posted will be well suited in the MSDN forums. Click on the link below.

    http://social.msdn.Microsoft.com/forums/en-us/category/VisualBasic

  • WordWrap on desktop hp2510

    How do you turn OFF wordwrap on a deskjet hp 2510 please.

    I want to print a .txt (text) file.

    One solution would be to cut the file before printing (with a python for example script) on a line width max - but how many characters/line should there be?

    Hello

    Depending on the font and size, you can't tell how many characters in a single line. Because they are text (txt) files, you can activate the ON / OFF wordwrap and you must REGISTER first then open again to print.

    Kind regards.

  • List of subdirectories in DataGrid

    I'm trying to list the files and subdirectories in a DataGrid and when the user clicks on a content directory to the directory displayed in the DataGrid control. I got the directories in the list but cannot get them to open.

    
    
    
    
    
    
    
    ....
    
    
    
    

    The listHandler is supposed to detect whether the event.target is a directory or not, and if it is to replace the contents of the DataGrid with the contents of the target.

    Yes, it's fake.  The 'target' is always the object generating the event.  So in your event sink, you need to:

    var currentFile:File = this.list.selectedItem.file as a file;

  • Data binding to DataGrid problem

    Hey guys, I have a quick question for you. I can not get my data appears in my DataGrid, and I probably do something stupid which is at the origin of the problem.

    To quickly explain, I'm out my DB given in my file DBClass, then return of the DBClass as a DataProvider function. When I get the DataProvider to return, I create a table, push my DataProvider inside, and then link to my DataGrid using new ArrayCollection (array). It sounds like a big NUMBER to Exchange around the types of variables, but I've not found an easier way to do it. I find it funny that I cannot bind my DataGrid dataprovider to a typed variable dataprovider, but I suspect it's because it's a spark datagrid and a dataprovider of qnx. If there is a better way, please let me know cause all these types of data are confused the hell out of me.

    In any case, here's the code:

    DBClass.as:

    var result:SQLResult = sqlStatement.getResult();
    var dp:DataProvider = new DataProvider();
    for each(var obj:Object in result.data) {
        if (obj != null) {
            dp.addItem({week:obj["week"], suHours:obj["su_end"], moHours:obj["mo_end"], tuHours:obj["tu_end"], weHours:obj["we_end"], thHours:obj["th_end"], frHours:obj["fr_end"], saHours:obj["sa_end"]});
        }
    }
    return dp;
    

    I don't understand the SQL statement or enforcement because this part is fine. It's just the DP put in place.

    viewHistory.mxml viewActivateHandler:

    protected function view1_viewActivateHandler(event:FlexEvent):void
    {
        var database:DBClass = new DBClass();
    
        var daHistory:Array = new Array();
        daHistory.push(database.getHistory(1));
    
        if(daHistory.length > 0)
            dgHistory.dataProvider = new ArrayCollection(daHistory);
    }
    

    getHistory (1) is back the DP from DBClass.as code listed above, the 1 is just a variable to determine what exactly to the back, so it is not related.

    viewHistory.mxml DataGrid:

    
        
            
                ... some custom itemrenderers that take up a lot of space ...
                
                
                
                
                
                
                
            
        
    
    

    I took out a couple of converters element custom in this last excerpt just to save space.

    Is that all the columns are empty instead of display the data provided in the table. I made the debug to prove that the RFP returned records and daHistory's records before being put in the ArrayCollection collection and defined as the dataprovider, so I don't know where I'll lose my data or setting of something wrong.

    Any help would be appreciated. As I said, all these types of data are a bit confusing, because it's a new language, I learn that I will. Thank you!

    Solved mine once again! I feel like all I have to do is post something here and I find myself the answer soon after. It's not like I've been stuck on this since yesterday, but regardless, it works.

    And to answer my question, Yes, I was going WAY out of how to get my data with too many data types.

    I've simplified the get function in DBClass.as to just return a table:

  • Progress within datagrid bar

    Hi all

    I have a datagrid in which I have to display the progress bar with the task completed in %.

    for example, I have two fields in a source meter table and counter of the completion.

    where source County in 100000 rows and 50000 lines have been inserted.

    in another table and status are displayed in the table.

    so I need to display in a progress bar that task of 50% has been completed.

    Any suggestions or ideas.

    Sample ex:

    progressbar.jpg

    Hello

    Here's something to play with:

    public class ProgressInTableTest {
        private static final Random RANDOM = new Random();
    
        private final class RunnableDummyProgressProducer implements Runnable {
            private final DefaultTableModel defaultTableModel;
            private final JProgressBar allProgress;
    
            private RunnableDummyProgressProducer(
                    DefaultTableModel defaultTableModel, JProgressBar allProgress) {
                this.defaultTableModel = defaultTableModel;
                this.allProgress = allProgress;
            }
    
            @Override
            public void run() {
                for (int i = 0; i < progressEntries.size(); i++) {
                    ProgressEntry progressEntry = progressEntries.get(i);
                    while (100 > progressEntry.progress * 100
                            / progressEntry.fileSize) {
                        progressEntry.progress += 10;
                        defaultTableModel.fireTableCellUpdated(i, 2);
                        try {
                            Thread.sleep(50);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }
                    progressEntry.progress = progressEntry.fileSize;
    
                    SwingUtilities.invokeLater(new Runnable() {
    
                        @Override
                        public void run() {
                            allProgress.setValue(allProgress.getValue() + 1);
                            allProgress.setString(String.format("%s / %s",
                                    allProgress.getValue(),
                                    allProgress.getMaximum()));
                        }
                    });
                    defaultTableModel.fireTableCellUpdated(i, 2);
                }
            }
        }
    
        private final class DefaultTableCellRendererExample extends
                DefaultTableCellRenderer {
            private static final long serialVersionUID = 1L;
    
            @Override
            public Component getTableCellRendererComponent(JTable table,
                    Object value, boolean isSelected, boolean hasFocus, int row,
                    int column) {
                Component rendererComponent = super.getTableCellRendererComponent(
                        table, value, isSelected, hasFocus, row, column);
                JTextField newRenderer = new JTextField();
                ProgressEntry progressEntry = progressEntries.get(row);
                switch (progressEntry.progress * 100 / progressEntry.fileSize) {
                case 0:
                    newRenderer.setText("pending");
                    return newRenderer;
                case 100:
                    newRenderer.setText("done");
                    return newRenderer;
                default:
                    rendererComponent = new JProgressBar(0, progressEntry.fileSize);
                    JProgressBar jProgressBar = (JProgressBar) rendererComponent;
                    jProgressBar.setValue(progressEntry.progress);
                    jProgressBar.setStringPainted(true);
    
                }
                return rendererComponent;
            }
        }
    
        private final class DefaultTableModelExample extends DefaultTableModel {
            private static final long serialVersionUID = 1L;
            private final String[] columnNames = { "file name", "file size",
                    "progress" };
    
            private DefaultTableModelExample(int rowCount, int columnCount) {
                super(rowCount, columnCount);
            }
    
            @Override
            public String getColumnName(int column) {
                return columnNames[column];
            }
    
            @Override
            public Class getColumnClass(int collumn) {
                switch (collumn) {
                case 1:
                    return Integer.class;
                case 2:
                    return ProgressEntry.class;
                default:
                    return String.class;
                }
            }
    
            @Override
            public Object getValueAt(int row, int column) {
                switch (column) {
                case 0:
                    return progressEntries.get(row).fileName;
                case 1:
                    return progressEntries.get(row).fileSize;
                case 2:
                    return progressEntries.get(row).progress;
                default:
                    return super.getValueAt(row, column);
                }
            }
        }
    
        public class ProgressEntry {
    
            private final String fileName;
            private final int fileSize;
            private int progress = 0;
    
            public ProgressEntry(String fileName, int fileSize) {
                this.fileName = fileName;
                this.fileSize = fileSize;
            }
    
        }
    
        private final List progressEntries = new ArrayList();
    
        @Test
        public void test() {
            initializeSampleData();
            JProgressBar allProgress = createFileCountProgress();
    
            DefaultTableModel defaultTableModel = new DefaultTableModelExample(
                    progressEntries.size(), 3);
            JTable table = createTable(defaultTableModel);
            startDummyProcess(allProgress, defaultTableModel);
    
            JPanel message = completeGUI(allProgress, table);
    
            JOptionPane.showMessageDialog(null, message, "ProgressTest",
                    JOptionPane.PLAIN_MESSAGE);
        }
    
        private JPanel completeGUI(final JProgressBar allProgress, JTable table) {
            JPanel message = new JPanel(new BorderLayout());
            message.add(new JScrollPane(table), BorderLayout.CENTER);
            message.add(allProgress, BorderLayout.SOUTH);
            return message;
        }
    
        private void startDummyProcess(final JProgressBar allProgress,
                final DefaultTableModel defaultTableModel) {
            new Thread(new RunnableDummyProgressProducer(defaultTableModel,
                    allProgress), "ProgressTest").start();
        }
    
        private JTable createTable(final DefaultTableModel defaultTableModel) {
            JTable table = new JTable(defaultTableModel);
            table.setDefaultRenderer(ProgressEntry.class,
                    new DefaultTableCellRendererExample());
            return table;
        }
    
        private JProgressBar createFileCountProgress() {
            final JProgressBar allProgress = new JProgressBar(0,
                    progressEntries.size());
            allProgress.setStringPainted(true);
            return allProgress;
        }
    
        private void initializeSampleData() {
            for (int i = 0; i < 20; i++) {
                progressEntries.add(new ProgressEntry(String.format("IMG_%03d.jpg",
                        i), RANDOM.nextInt(1000)));
            }
            for (int i = 0; i < 3; i++) {
                progressEntries.get(i).progress = progressEntries.get(i).fileSize;
            }
            progressEntries.get(3).progress = 50;
        }
    }
    

    Good bye

    DPT

Maybe you are looking for