Hello,
I use the igGrid with a single column template like http://jsfiddle.net/yuz7LwLa/.
My problem : i can't find a way to add event listeners on element of my template.
In the jsfiddle example, i have the template :
<div style='float: left;'> <img width='100' height='90' src='${ImageUrl}'></img></div><div class='right' style='float: left; font-size: 1.1em;'> <span>Name: </span><span>${ProductName}</span><br/> <span>Category: </span><span>${CategoryName}</span><br/> <span>Units In Stock: </span><span>${InStock}</span><br/></div>
How can i add a listener in my img, after row added in DOM?
Is there an event that give the tr or the td added in the grid as parameter like
OnRowReady(grid, args) { var generatedRowOrCell = args.row; jQuery("mySelectorForFindMyImg", args.row).on("click", function() { console.log("Yeah! You find a way to add listener"); }}
I know it is possible to add onclick attribute in the template, but in my real case, the template is more complex and i need to call a class function with js closure.
Thanks for your reply
Yoann.
Hello Tsanna,
I will try to compose with this event.
Thank you.Yoann
Hello Yoann,
I suggest you to use rowsRendered event in this case: https://www.igniteui.com/help/api/2016.2/ui.iggrid#events:rowsRendered because it fires after data rows are rendered and you can get the rendered rows DOM elements through its ui event parameter, for instance:
ui.tbody.children("tr")
Please note that this will return all rendered row elements, but you can access certain row element using a loop.
If you need further assistance regarding this matter, feel free to ask.
Regards,
Tsanna