Extracting data from a grid on webpage

  • I have an internal site which has a very complicated javascript code.


    I need to extract a value of InvoiceNo form a given InvoiceID. I will then use this InvoiceNo to conpose a URL to go to.


    It seems that there is a table/grid on the page. (The invoiceNo column is not shown, however i can see the corresponding values in the source code)


    The web code for this part is:

    Code
    1. var grid = $find("dgrdInfo");
    2. .
    3. .
    4. .
    5. .
    6. var str = grid._rows.get_row(eventArgs.get_item()._row._address).get_cellByColumnKey("INVOICE")._element.firstChild.nodeValue;
    7. window.open('CustomerCollections.aspx?ScreenType=invoicedetails&InvoiceNo=' + str + '&CustomerNo=' + custNumber, '_self');




    Note: I could either use the hyperlink on the Invoice Id column on the page. The table is created with a very complicated javascript code i cannot get to locate the link by looping through all hyperlinks on the page. (There are also no frame tags on the page)



    Request any folks here who have knowledge around this to help me.

  • Re: Extracting data from a grid on webpage


    Hi mentos123


    Java can be the pits
    one method were you wait for the java to update then use HTMLDoc.body.innerHTML

  • Re: Extracting data from a grid on webpage


    Thanks Pike for helping me out ... but I cannot understand much of the code from the link.


    But Let me try to explain.....
    I am pasting a piece of code here which I think forms the table and displays the first row. There were a lot of fields and formatting code which I have removed to keep the code short. In the code there is a value XXXXXX (Invoice number) which I want to obtain by providing the value YYYYYY (Invoice Id) which I have. I will then use this XXXXXX to create a link and then navigate forward.





    Would request you to have a look at advise if I can get the value I need by any method.

  • Re: Extracting data from a grid on webpage


    Hello,
    Looks like you can get the data using the HTML Object Model and referencing the "MS HTML Object Library" in the VBE >Tool> References
    but hard to say with a snipet of HTML code.
    Can you copy all the code to a txt file and attach it ti the forum?
    maybe something like


  • Re: Extracting data from a grid on webpage


    Thanks Pike. I will try this on Tuesday when I get back into my office network.


    This is where I stand now:
    1. I was able to modify your code in the other thread http://www.ozgrid.com/forum/showthread.php?t=187341 Post #3 and extract the table to excel (That includes the invoice id and invoice no. columns!!)
    2. I could do this because the table id for the table was unique (x:558988790.30:mkr:outerTbl.hdn in the code I pasted)
    3. There are however extra rows (one before each actual row) which contains some values I don't recognize. (the first cell in such rows is a concatenation of all values in the next actual row)
    4. I would love if I did not have to dump the data into excel and could just get the XXXXXX value from a given YYYYYY value. But I can work with table dump too (do a vlookup and delete the table data from excel)
    5. I looked into the code with the data of a few other invoices and it seems that the class id of the two columns remains constant as in the example. (Maybe this could be used to get the data, not sure)


    I will try and upload a bigger chunk of code on the thread on Monday if I can't get it to work with the code you gave me. Will have to do a lot of clean up of data before I do so or I will lose my job :)

  • Re: Extracting data from a grid on webpage


    Pike, This isindeed dumpingthe table to excel. I have one small concern though.


    There is an extra row above each row I . e.g i have 9 rows on the Web browser but the objTable count says 18 while debugging. Must be a backend thing. Can I just dump the rows based on a TR class ID. I have noticed that the 9 rows I need have a different class ID from that of the 9 rows i do not need.


    Also.... can I also just do a direct lookup from the code without having to dump the table.


    Thanks again.

  • Re: Extracting data from a grid on webpage


    Hi Pike,


    I could save the need to download the entire table if I could just click on a link on the page. Each invoice ID in the table is a clickable link but the link is created dynamically from a class.


    I am unable to attach any files from my office system but I will try and paste a snippet of the code which creates the fields in the columns. If only I could click those link, my job is done.