Link to home
Start Free TrialLog in
Avatar of ZIVEM
ZIVEM

asked on

Is it possible to iterate through DataGrid Items with JavaScript ?

how can this be accomplished ?
Avatar of bpmurray
bpmurray
Flag of Ireland image

Whenever any tabular data are displayed on a page, it is possible to iterate through them using JS. However, the exeact implementation depends on where the component came from. Which DataGrid are you using? Something MS created? From JSF? You see the source of the component determines the exact markup that's displayed. If you could paste the generated source of the datagrid, it would help identify what to access.
Avatar of ZIVEM
ZIVEM

ASKER

i get table with TR and TD's like this one.
my Grid has first and last names.

       <table cellspacing="0" cellpadding="3" rules="all" border="1" id="MyDataGrid" style="border-color:Tan;font-family:Arial;font-size:9pt;width:800px;border-collapse:collapse;">
      <tr style="color:White;background-color:#336699;font-weight:bold;">
            <td align="center">Edit</td><td align="center">Delete</td><td><a href="javascript:__doPostBack('MyDataGrid$ctl02$ctl00','')" style="color:White;">id</a></td><td><a href="javascript:__doPostBack('MyDataGrid$ctl02$ctl01','')" style="color:White;">First Name</a></td><td><a href="javascript:__doPostBack('MyDataGrid$ctl02$ctl02','')" style="color:White;">Last Name</a></td><td><a href="javascript:__doPostBack('MyDataGrid$ctl02$ctl03','')" style="color:White;">permission</a></td>
      </tr><tr style="background-color:#EEEEEE;">
            <td align="center" style="width:70px;"><a href="javascript:__doPostBack('MyDataGrid$ctl03$ctl00','')"><img src='gui/icon/application_form_edit.gif' border=0 /></a></td><td align="center" style="width:40px;"><a href="javascript:__doPostBack('MyDataGrid$ctl03$ctl01','')"><img src='gui/icon/application_form_delete.gif' border=0 /></a></td><td valign="top" style="white-space:nowrap;">71</td><td>
            john
          </td><td>
            weis
          </td><td>
            1
          </td>
      </tr><tr style="background-color:#EEEEEE;">
            <td align="center" style="width:70px;"><a href="javascript:__doPostBack('MyDataGrid$ctl04$ctl00','')"><img src='gui/icon/application_form_edit.gif' border=0 /></a></td><td align="center" style="width:40px;"><a href="javascript:__doPostBack('MyDataGrid$ctl04$ctl01','')"><img src='gui/icon/application_form_delete.gif' border=0 /></a></td><td valign="top" style="white-space:nowrap;">60</td><td>
            Dan
          </td><td>
            Kerr
          </td><td>
            1
          </td>
      </tr><tr style="background-color:#EEEEEE;">
            <td align="center" style="width:70px;"><a href="javascript:__doPostBack('MyDataGrid$ctl05$ctl00','')"><img src='gui/icon/application_form_edit.gif' border=0 /></a></td><td align="center" style="width:40px;"><a href="javascript:__doPostBack('MyDataGrid$ctl05$ctl01','')"><img src='gui/icon/application_form_delete.gif' border=0 /></a></td><td valign="top" style="white-space:nowrap;">70</td><td>
            Cristian
          </td><td>
            Luxford
          </td><td>
            2
          </td>
      </tr><tr style="background-color:#EEEEEE;">
            <td align="center" style="width:70px;"><a href="javascript:__doPostBack('MyDataGrid$ctl06$ctl00','')"><img src='gui/icon/application_form_edit.gif' border=0 /></a></td><td align="center" style="width:40px;"><a href="javascript:__doPostBack('MyDataGrid$ctl06$ctl01','')"><img src='gui/icon/application_form_delete.gif' border=0 /></a></td><td valign="top" style="white-space:nowrap;">54</td><td>
            Ben
          </td><td>
            Turner
          </td><td>
            3
          </td>
      </tr><tr align="right" style="background-color:#C6C3C6;font-size:Smaller;">
            <td colspan="6"><span>1</span>&nbsp;<a href="javascript:__doPostBack('MyDataGrid$ctl08$ctl01','')">2</a></td>
      </tr>
</table>
ASKER CERTIFIED SOLUTION
Avatar of bpmurray
bpmurray
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ZIVEM

ASKER

that's great!
thanks