Shantanu Tomar
Shantanu Tomar

Reputation: 1712

How to get column name in dojo grid.

I want to retrieve a particular column name and perform an event on that . how to do that . ? using dojox.grid.datagrid. Like currently i have 3 columns or fields in my grid(ID, names,Email). I want that for a particular column Email. When i click any value under that column the dialog box should not open. But when i click on any where else(on other 2 columns on a particular row) it opens up.

Upvotes: 0

Views: 5262

Answers (2)

Vijay Agrawal
Vijay Agrawal

Reputation: 3821

if you want the dialog to open upon clicking a value in that column (and not the entire cell, which includes whitespace in the cell), then you can use the format function for that field and return a HTML that is an anchor element or any other HTML that is clickable.

for example:

in the grid structure:

columns: [{
label: "Email",
attr: "emailid",
formatter: formatEmail
},
...

function formatEmail(data, item, store) {
    return "<a href='mailto:" + data + "'>" + item.nameOfPerson + "</a>";
}

Upvotes: 0

Chris Li
Chris Li

Reputation: 3725

You can connect grid's onCellClick event and get row/col info from the argument. For example:

dojo.connect(grid, "onCellClick", function (e) {
    var colField = e.cell.field; // field name
    var rowIndex = e.rowIndex; // row index
    ....
});

And add your logic in the event handler based on those informations.

Upvotes: 4

Related Questions