Categories | Question details Back To List | ||
Adding lmages to a cell with onclick javascript functions I am initializing a grid using loadXML, this default loaded grid work fine, but when a add a row with the next code: mygrid.addRow(Idx,'[AUTO],<IMG alt="SETI" src="../temas/botones/exclamation.png" width="16" height="16" border="0"^javascript:eliminar("0")^_self>',nrow); add a row corectly displayed but the click event on image open a new window whit a URL=javascript:eliminar("0") on the other hand the same image in previously loaded grid work fine executing the function eliminar("0"). So the question is how can i do to put an image on a grid using addRow() capable of trigger a javascript function? thanks in advance. Sorry about my english.! Answer posted by Support on Mar 04, 2008 02:07 There are multiple ways to provide javascript actions from cell, the most simple - just use plain HTML as cell value mygrid.addRow(some_id,[1,"<img src='some.gif' onclick='doSome();',2] />"); Others are next a) Use "link" excell and formated data <cell>Text^javascript:Action^_self</cell> <cell>Delete Alert?^javascript:confirmDelete("some")^_self</cell> such code will create an A tag, with javascript action attached to it b) Use "ro" excell and HTML value <cell><![CDATA[<a href='#' onclick='Action'>Text</a>]]></cell> <cell><![CDATA[<a href='#' onclick='confirmDelete("some")'>Delete Alert?</a>]]></cell> c) Use the setOnRowSelectHandler method grid.setOnRowSelectHandler(my_func,true); function my_func( rowId, cellIndex){ if (cellIndex==some_index) confirmDelete("some") } d) create a custom excell |