Trouble adding buttons to cells

Hi all,

Quick noob question, all I need to do is add a couple of buttons to the last col of each row that execute some javascript when pressed I’ve read a number of the posts on the forum and tried whats been suggested but none of it seems to work.

I’ve tried creating my own excell types but it did’nt work and seemed way to complex for what I need my latest attempt is this:

[code] mygrid.init();
var count = mygrid.getRowsNum();
alert (count)
for (var i = 1; i< count; i++) {

                mygrid.cells(i,7).setCValue("<input type='button' value='Zoom'></input>");

Again I know its probably way off but Im pretty new at this and still learning :slight_smile: , can one of you good people point me in the right direction?

you could add a separate column for each “button” and use the cell type “image” to load an icon in each column - eg for Add, Delete, Edit
when you load the form data set the column to correct path to the image - eg …/images/add_icon.gif
(the paths will be static values for all rows)

you can then use -
grid.attachEvent(“onRowSelect”, function(id,ind){
alert("you clicked the image in column " + ind + " on row " + id);
… do something

Thanks for that,

But forgive my ignorance wont that fire when ever any given row is selected ?
What I’m looking for is something that will only be fired when a specific column cell is selected.

Hi all,

Managed to get the buttons in each cell of the last column (ended up using an image instead but the principal is the same) heres the code I used for reference, probably old news to most of you but it may come in handy for other noobs like me :slight_smile: .

for (var i = 0; i < mygrid.getRowsNum(); i ++ ) {
var cellObj = mygrid.cellByIndex(i,getColumnNum());

you are correct that the “onRowSelect” fires each time a user selects a row but the function it creates has the id of the row AND the column that was clicked.

You may try to add a simple html button in your cell:

		<cell class=""><![CDATA[<input type="button" onclick="alert ('clicked!')" value="push">]]></cell>