Programmactic Access DataGrid Rows and Columns

Hello,
I am new to ActionScript. Can you tell me how can I access
the rows and columns of a data grid?
What I want to do is that when the application load, I will
populate the datagrid with the Xml returned from the webservice.
After that, webservice will be called periodically (using timer)
and the information in the datagrid needs to be updated. The cells
which are updated need to be highlighted.
The datagrid actually contains the stock market data (symbol
name and its other attributes). So once the datagrid has been
populated on application creation, it contains all the symbols in
the market. After that, only attributes of the symbols will change,
like price, volume etc. What I want is that once the datagrid is
populated, i can access the row by using the value of symbol code
and then update the appropriate columns of that symbol. (Xml from
next time will contain only symbols whose values change from last
time).
Below is the code that I have written so far.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
layout="absolute"
creationComplete="OnAppCreationComplete()" width="100%"
height="100%">
<mx:Script>
<![CDATA[
import mx.rpc.events.ResultEvent;
private var count:uint = 0;
private var messageFramXmlList:XMLList;
private var marketSnapshotTimer:Timer = new Timer(1000);
private function OnAppCreationComplete() : void
this.ajaxServiceInvokerProxy.addEventListener(ResultEvent.RESULT,
this.OnWebServiceResultArrived);
this.ajaxServiceInvokerProxy.InvokeService.send();
this.marketSnapshotTimer.addEventListener(TimerEvent.TIMER,
this.OnSnapshotTimerTick);
this.marketSnapshotTimer.start();
private function
OnWebServiceResultArrived(event:ResultEvent) : void
var marketSnapshotXml:XML = new XML(event.result);
this.messageFramXmlList =
marketSnapshotXml.child("MarketSnapshot").child("MessageFrameList")[0].child("MessageFram e");
this.dgTopPosts.dataProvider = this.messageFramXmlList;
this.btnCounter.label = this.count.toString();
private function OnSnapshotTimerTick(event:TimerEvent) :
void
this.count++;
this.ajaxServiceInvokerProxy.InvokeService.send();
]]>
</mx:Script>
<mx:WebService id="ajaxServiceInvokerProxy"
wsdl="
http://jehanzeb/ajaxserviceinvoker/ajaxserviceinvoker.asmx?wsdl"
useProxy="false">
<mx:operation name="InvokeService">
<mx:request>
<serviceWithComonentName>DetailedSnapshotComponent.MarketSnapshot@TADAWUL</serviceWithCom onentName>
<parametersXml><![CDATA[ <Parameters/>
]]></parametersXml>
</mx:request>
</mx:operation>
</mx:WebService>
<mx:Panel x="10" y="10" width="100%" height="100%"
layout="absolute" title="Market View">
<mx:RichTextEditor id="txtMarketViewResult" x="10" y="10"
width="612" height="194" />
<mx:DataGrid x="10" y="223" id="dgTopPosts" width="100%"
height="303">
<mx:columns>
<mx:DataGridColumn headerText="Symbol Code"
dataField="SymbolID" />
<mx:DataGridColumn headerText="Last Time"
dataField="LastTime" />
<mx:DataGridColumn headerText="Net Change"
dataField="NetChange" width="75"
/>
<mx:DataGridColumn headerText="Percent Change"
dataField="PercentChange" width="75" />
<mx:DataGridColumn headerText="Previous Closed"
dataField="PreviousClosed" width="75"/>
<mx:DataGridColumn headerText="Close" dataField="Close"
width="75"/>
<mx:DataGridColumn headerText="Direction"
dataField="Direction" width="75"/>
<mx:DataGridColumn headerText="BidPrice"
dataField="BidPrice" width="75"/>
<mx:DataGridColumn headerText="AskPrice"
dataField="AskPrice" width="75"/>
<mx:DataGridColumn headerText="BidVolume"
dataField="BidVolume" width="75"/>
<mx:DataGridColumn headerText="AskVolume"
dataField="AskVolume" width="75"/>
</mx:columns>
</mx:DataGrid>
<mx:LinkButton id="btnCounter" x="10" y="528" width="306"
textAlign="left" label="" />
</mx:Panel>
</mx:Application>

To achieve what you want, I would have two functions:
* One populates the DataGrid for the first time, i.e. the
inital load
* The other does the 'update' on each interval, since there's
logic required
To update the DataGrid with only the rows that have changed,
you're going to have to compare
the incoming XML to the existing XML in the dataProvider of
the DataGrid, then selectively update the dataProvider.
You can use the
getItemAt() and
setItemAt() methods of the data provider to check each row
against the incoming data. So, some example code:
// This is the function which handles the result of your
'updated data only' webservice
private function handleUpdateInvoke (event:ResultEvent) :
void {
var incoming:XML = new XML(event.result);
var someList:XMLList = incoming.somePattern;
// For each data provider item, check the key and if it
matches
// one of the incoming keys, update it at that index
var numRows = this.dgTopPosts.dataProvider.length;
var existingDataRow:*
for (var i:Number = 0; i < numRows; i++) {
existingDataRow = this.dgTopPosts.dataProvider.getItemAt(i);
for each (var newDataRow:* in someList) {
if (existingDataRow.SymbolID == newDataRow.SymbolID) {
this.dgTopPosts.dataProvider.setItemAt(newDataRow, i);
}

Similar Messages

  • Suppressing  the total row and column in OLAP datagrid

    I have created an OLAPDatagrid and everything looks fine
    except that I don't want to show the '(All)' row and column in the
    grid. Is there a way to suppress them?
    Thanks,
    Fred

    Instead of using members() in the query use children() for
    the attribute/hierarchy.

  • How to save data from JTable multiple rows and columns

    Hi Y_Not thanks for your help before...
    But what should I do if I want to get/save many data from many column and rows??

    i don't quite understand your (repeated) question. what is the problem with "multiple rows and columns". Y_NOT and i have shown you ways to access them.
    all you need are 2 loops: one around your number of rows and one around the number of columns or vice versa depending in which order you want to save things:
    for (int col = 0; col < data.size(); col++) {
        for (int row = 0 ; row < data[col].size(); row++) {
            // save your data
            saveData(data[col].getElementAt(row));
            // or use yourtable.getValueAt(row, col);
    }this is not a problem of Swing/Java but of simple algorithm...
    thomas

  • How can i open a PDF bank statement in numbers so that the rows and columns contain properly aligned data from statement?

    how can i open a PDF bank statement in "numbers" so that the rows and columns contain properly aligned data from statement?

    Numbers can store pdfs pages or clippings but does not directly open pdf files.  To get the bank statement into Numbers as a table I would open the bank statment in Preview (or Skim) or some pdf viewer.
    Then hold the option key while selecting a column of data.
    Then copy
    Then switch to numbers and paste the column into a table
    Then repeat for the other columns in the pdf document
    It would be easier (in my opinion) to download the QFX or CSV version from your bank

  • How to get number of rows and columns in a two dimensional array ?

    Hello,
    What would be the simplest way to get number of rows and columns in a two dimensional array represented as integers ?
    I'm looking for another solution as For...Each loop in case of large arrays.
    Regards,
    Petri

    Hi Petri,
    See a attached txt file for obtaining two arrays with upper and lower index values
    Regards
    Ray
    Regards
    Ray Farmer
    Attachments:
    Get2DArrayIndex.txt ‏2 KB

  • How do I delete multiple rows and columns in an image?

    I am looking into how digital SLRs extract video data from a CMOS sensor. To give an example, the GH1 from Panasonic can record video at 1920 x 1080 from a 12 MPixel sensor that, say, is 4000 horizontal x 3000 vertical. How they do that seems to be not in the public domain, but there have been a few guesses (see http://www.dvxuser.com/V6/showthread.php?t=206797 and http://luminous-landscape.com/forum/index.php?showtopic=38713).
    One approach would be to simply read every second row of sensor pixels (1500 rows read from the original 3000) and once you have those in memory, delete every second column (2000 columns left). You would end up with a 2000 x 1500 image which could then be resampled to 1920 x 1080.
    I'd like to simulate what the camera appears to be doing, by generating a 4000 x 3000 test image and then asking Photoshop CS4 to delete the appropriate rows and columns. It may not necessarily be every second row; the Canon 5DMk11 appears to read every third row, so I may need to delete two out of every three rows.
    Can Photoshop do that sort of thing? If so, how?

    Thanks for the suggestions. Yes, I did take a detailed look at your images, but they weren't 100% convincing because it wasn't clear just what was happening. And Adobe's explanation, after reading it again, explains nothing at all to someone who doesn't know how Nearest Neighbor works.
    But you are correct -- Nearest Neighbor does effectively delete pixels. I proved it with the attached 6 x 6 image of coloured pixels (the tiny midget image right after this full stop -- you'll have to go to maximum zoom in PS to see it).
    These are the steps to delete every second row and then every second column.
    1. Select Image > Image Size.
    2. Set Pixel Dimensions > Height to half the original (in this case set to 3 pixels).
    3. Set Resample Image to Nearest Neighbor.
    4. Click OK and the image shoould now consist of three vertical white strips and three vertical Green-Red-Blue stripes.
    5. Repeat steps 1-4, but this time set Pixel Dimensions > Width to half the original (in this case set to 3 pixels). The image should now consist of three horizontal stripes Green-Red-Blue.
    Just to make sure the method worked for every third pixel, I repeated the above steps but with 2 pixels instead of 3 and obtained the correct White-Green, White-Green pattern.
    I resampled the Height and Width separately for the test so that I could see what was happening. In a real example, the height and width can be changed at the same time in the one step, achieving the same results as above.
    Finally, how to explain how Nearest Neighbor works in the simple cases described above?
    Division by 2
    In the case of an exact division by two (pixels numbered from top leftmost pixel), only the even numbered rows and columns remain. To put it a different way, every odd numbered row and column are deleted.
    Division by 3
    Only rows and columns 2, 5, 8, 11... remain.
    Division by N
    Only rows and columns 2, 2+N, 2+2N, 2+3N... remain.
    To put it simply, a resample using Nearest Neighbor (using an exact integer multiple) keeps every Nth row and column, starting from number two. The rest are deleted.

  • Lock rows and columns header in a table view report. It is possible?

    hi,
    I have a Dashboard that displays a report in "Table View" with many rows and columns.
    Is it possible to set a lock on the rows and columns like Excel?
    This would have blocked such headers that contain attributes and measures and to browse the report (eg with a scroll bar) had always viewed the headers.
    Can you help me?
    Thanks

    hi,
    please go through this discussion
    Re: SCROLL BAR to FREZZ HEADERS
    thanks,
    saichand.v

  • Is it possible to switch the rows and columns?

    Is it possible to switch the rows and columns of a table? The reason I ask is that it would be easier for me to input the data with the number at the top of a column and the fields going down. But it would be easier to read the data with the number on the left and the fields going to the right. Is it possible to switch a table in this way?

    mahongue wrote:
    Is it possible to switch the rows and columns of a table? The reason I ask is
    that it would be easier for me to input the data with the number at the top
    of a column and the fields going down. But it would be easier to read the
    data with the number on the left and the fields going to the right. Is it
    possible to switch a table in this way?
    It sounds to me as though you wish to transpose a table so that the original is changed from rows to columns and from columns to rows, as in the following:
    Table 1
        A   B   C
    ========
    1   o   p   q
    2   r   s   t
    3   u   v   w
    Table 2
        A   B   C
    ========
    1   o   r   u
    2   p   s   v
    3   q   t   w
    You are right - it would be nice to have a menu item to magically transpose a selected block of cells. But there isn't one. So...
    One way to solve this is to use the index() and transpose() functions to accomplish row and column cell transposition. If you are going to use a 1:1 cell correspondence and change the header columns and rows also, you can use this:
       =INDEX(TRANSPOSE(Table # :: <range>),ROW(),COLUMN())
    where Table # and <range> is substituted as in the following fashion:
       =INDEX(TRANSPOSE(Table 1 :: $A$1:$C$3),ROW(),COLUMN())
    Create a second table. Copy the modified formula above with the appropriate substitutions, select the range you wish to have your transposition inserted into (must match the transposed cell dimensions of the original range), paste the forumula and voila! the cells will be transposed.
    Cautions:
    o The target table must match the swapped cell length and width dimension. For example, if the original data range is 6 columns wide by 4 rows deep, then the corresponding table or range to hold the transposition must be 4 columns wide by 6 rows deep.
    o If your transposed data block is to be offset from the origin of the new table, then you will need to include a subtractive offset into your cell formula, since in the transpose() function the data in the master data range is referenced from its position with the master range, not its cell position in the table. Such an offset is necessary because this example formula uses the target row and column numbers to arrive at indexed positions.
    For example, if the new data range is to be offset one column to the right and one row below from the target table's origin then you must subtract (-1) from the cell and from the column references in the formula:
      Example:
      =INDEX(TRANSPOSE(Table 3 :: $B$2:$D$4),ROW()-1,COLUMN()-1)
    If someone has a better solution I'd be glad to hear of it.

  • How Calculate more than one value and store it into to different rows and column for each input?

    thx guys.....i have a progress now in LV
    But now i have new trouble here. Ok i attached my LV file (LV 7.0.1/7.1) and excel form. I just could'nt calculate more than one input value. I want a different result for each value that i enter ... and store it into different rows and column. But it just store at one row.
    Attachments:
    My Project.vi ‏31 KB
    rumus motor bakar.xls ‏14 KB

    duplicate post

  • Keeping row and column headers while scrolling inside a Web Dynpro table

    Hi,
    I have to display a 2x2 matrix with storage location names on the x-axis (i.e. as Column Headers) and material names on the y-axis (i.e. row headers). The table data represents the quantities of a particular material in a particular storage location.
    I am using dynamic UI generation to create this table. It can contain as many as 150 columns and almost as many rows. I dont want a page level scrollbar, and hence, have placed my table inside a scroll container UI element with a fixed height and width.
    I need a way to let the users use the scrollbars inside the scroll container, but still let them see the row  and column headers. Is there a way that I can do this in Dynpro for Java?
    Thanks,
    Navneet Nair.

    Hi Kenn,
    You are probably better off posting this request in this forum User Interface Development in ABAP as you are more likely to get a response.
    Cheers,
    Neil.

  • Make Select rows and columns as read only in Table Control

    Hi All,
    I would like to know how to make certain cells in a Table Control as display only.
    Table control should look like-(Those in bold are read only or in display mode)
    <b>Name1            Idno1 </b>         Address1
    <b>Name2            Idno2</b>          Address2
    <b>Name3            Idno3  </b>        Address3
    <b>Name4            Idno4</b>          Address4
    (Blank row to enter name idno and address)
    (Blank row to enter name idno and address)
    (Blank row to enter name idno and address)
    My table control should display all the above fields the way it is above of which first two colums and 4 rows should be read only,and the rest of the empty rows in the TC should be in change mode.i.e it must have provision to add new rows but not change the first two columns of existing rows.
    In short I am looking at solution to hide particular no of rows and columns and <b>not the entire column.</b>

    In the PBO of the table control loop. just write these statements
    NAME and IDNO considering the fields on the screen.
    and WA_TAB is the table work area being passed to the table control to display the rows.
    if not WA_TAB-NAME is initial and not WA_TAB-IDNO is initial.
    loop at screen.
    if screen-name = 'NAME' or
       screen-name = 'IDNO'.
    screen-input = <b>0</b>.
    modify screen.
    endif.
    endloop.
    endif.
    which means that the fields are disabled only if NAME and IDNO are not initial.
    Regards
    - Gopi

  • Hi, how can i break the value for a row and column once i have converted the image to the array?????​??

    Hi, I would like to know how can i break the value for a row and column once i have converted the image to the array. I wanted to make some modification on the element of the array at a certain position. how can i do that?
    At the moment (as per attachhment), the value of the new row and column will be inserted by the user. But now, I want to do some coding that will automatically insert the new value of the row and the column ( I will use the formula node for the programming). But the question now, I don't know how to split the row and the column. Is it the value of i in the 'for loop'? I've  tried to link the 'i' to the input of the 'replace subset array icon' , but i'm unable to do it as i got some error.
    Please help me!
    For your information, I'm using LABView 7.0.

    Hi,
    Thanks for your reply.Sorry for the confusion.
    I manage to change the array element by changing the row and column value. But, what i want is to allow the program to change the array element at a specified row and column value, where the new value is generated automatically by the program.
    Atatched is the diagram. I've detailed out the program . you may refer to the comments in the formula node. There are 2 arrays going into the loop. If a >3, then the program will switch to b, where if b =0, then the program will check on the value of the next element which is in the same row with b but in the next column. But if b =45, another set of checking will be done at a dufferent value of row and column.
    I hope that I have made the problem clear. Sorry if it is still confusing.
    Hope you can help me. Thank you!!!!
    Attachments:
    arrayrowncolumn2.JPG ‏64 KB

  • How to increase the row and Column length of Bex query in EP Portal 7.3

    Dear All,
    Please let me know the process  to Increase the Rows and Columns  Size of Bex Query in Enterprise Portal  of SAP  7.3 .
    Please  let settings to increase rows up 10000 and column 100 in one page.
    Thanks
    Regards,
    Sai

    Dear All,
    Please find the attached screen shot.
    The report be open with 4 or 5 columns and 5 or 6 rows.
    So, please  let me know how to increase the length of the table.
    Do the needful for me to over come this issue.
    Thanks
    Regards,
    Sai.

  • Getting Row and Column in ADF RC

    Hi,
    I have an ADF RC form with a table control on it. I need to find the row and column of the cell where the user has clicked. I am able to get the row using getSelectedRow() but am not able to get the column of the cell. Could anyone please help?
    Thanks & Regards,
    Mike

    Hi Frank,
    I need the coordinates. eg. My table is something like this
    Country Region City Value1 Value2 Value3 Total
    AAAAA BBBBB XXX 10 15 30 55
    EEEEE YYY 5 2 15 22
    TOTAL 15 17 45 77
    etc.
    If the user clicks on any cell in the country column he can add countries, if he clicks on any cell in the region column, he can add regions. The behavior changes for value1, value2, value3... if he clicks in any of these columns he can add value4, value5 columns. If he clicks on the actual data, he gets another screen.
    Thanks & Regards,
    Mike

  • Goto row and column in a JTextArea

    Does anybody here know the correct procedure to get to a specific row and column in a JTextArea? I want to be able to do something like this:
    replace(char c, int row, int column) - where the original character at row,column will be replaced with c.
    I know that in C++, there is a windows console library that lets u do this, but there isn't one in java so I'm trying to get around it using a JTextArea.
    Thank you.
    Any Help/Comments/Ideas will be greatly appreciated.
    -Patrick

    JTextArea has a replaceRange method.
    John

Maybe you are looking for

  • Writing a report file with specific information

    Hi, all: I need to write a text file with specific information in it. I'm going to copy it into Excel, so the easier the format, the better (perhaps CSV format?). I've never done this before, so here's the method I need to capture the information fro

  • I want to delete all my past apple id and password and activate my current apple id and password

    I Want to delete all my pass apple id and password and avtivate my current apple id so i can updates all my staffs and i can download music .i cant do all this bec. My pass apple id and password always appears everytime i try to update <Personal Info

  • Help needed with Elements 11 reinstallation.

    ???  The hard drive on my new computer with Windows 8.1 is being replaced because it is defective.  How do I reinstall Photoshop Elements 11 ?  I Have a disc but was told it will only download one time  ---  which I did in January. Also, why can't I

  • OWB 11.2 and OBII

    Hello, actually we have an Oracle-DB 11.1 with OWB 11.1 and Oracle Business Intelligence 10.1.3.4. Now we want to use OWB 11.2. So we have to update the DB-Repository to 11.2. That should make no problems - i hope. But is Oracle Business Intelligence

  • Adobe Dreamweaver CS3 with ASP coldfusion and PHP search?

    I am working through Adobe Dreamweaver CS3 with ASP coldfusion and PHP with the intent of creating a data base site that primarily requires a search engine on the index page. The search page in the book uses specific search criteria ensuring that the