Search code examples
dojodojox.grid.datagriddojox.grid

Event handling on images displayed in datagrid


I have a dojo datagrid displaying records. I am displaying image enter image description here on each row. On click of the image, a request to delete the record should sent to the server. I am setting structure to the grid in Js class file. I have formatted the column to display the image as below.

GridStructure= [
   {
    name: "Name",
    field: "Name",
    width: "100px",
    rowSelector : '20px'
    },
{
    name: '',
    width: '20px',
    field: "",
    formatter: function(inValue) {
        this.customStyles.push("vertical-align:middle");
        return "<img src='images/delete.jpg'/>";
    }
}]

how should I handle the onclick event of image and call another JS method which will pass the row details to the business layer for further processing.

Thanks in advance.


Solution

  • I got it working but with a twist. Instead of writing event handling on images, I wrote it on the cell holding that image. So that way I get all the details about row index, the data in the row, everything. that served my purpose. :)