Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
170
adding click event to element of cell of grid on client
posted

hello,

i have a templatecolumn containing a checkbox as its celltemplate in the grid. i add rows to this grid on the client. while adding rows, when i am at this templatecolumn  cell i do -  ele=row.getCell(3).Element;  $addHandler(ele,"click",SelectRow); . the SelectRow function expects the checkbox object as its parameter, so that to check whether the checkbox is checked or unchecked. but it seems that i get some other object other that the checkbox in the SelectRow when it is invoked. i tried  ele=row.getCell(3).Element.children[0] too.

regards,

Parents
No Data
Reply
  • 28464
    posted

    Hello,

    In this case SelectRow most probably receives as a parameter the Element of the cell which is a <td> element. I can suggest going down from this element and using 

    getElementsByTagName("INPUT")[0]

    to get the first checkbox, or directly hooking the event on the checkbox in the template, e.g

    <CellTemplate>

         <input type="checkbox" onclick="SelectRow()"  .. />

    </CellTemplate>

    this way, the reserved keyword "this" will have the instance of the checkbox inside the event handler.

    Hope this helps.

Children