Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Joachim Kathmann on Oct 19, 2007 09:45
open dhtmlx forum
HTML button/image in a cell

Hi,

we've just purchased the Pro version of dhtmlXGrid and we have a question:
We want to have edit/delete/select/etc. functions for the records represented by rows of the grid (not in place editing).
So what we need to do is put some buttons or image icons in a column of the grid with links to pages or javascript functions. But how?

Creating CDATA HTML code inside a cell gives us all kinds of errors with quotation marks when putting that in the sourcecode of the page via PHP.

Is there an easy way to create a new exCell type button and use that as column.

Thanks in advance
Joachim Kathmann, i22.de GmbH
Answer posted on Oct 22, 2007 02:33
Actually solution with CDATA is most simple one but threre are some other ones

There are multiple ways to provide javascript actions from cell

a) Use "link" excell and formated data
                <cell>Text^javascript:Action^_self</cell>
                <cell>Delete Alert?^javascript:confirmDelete("some")^_self</cell>
such code will create an A tag, with javascript action attached to it

b) Use "ro" excell and HTML value
                <cell><![CDATA[<a href='#' onclick='Action'>Text</a>]]></cell>
                <cell><![CDATA[<a href='#' onclick='confirmDelete("some")'>Delete Alert?</a>]]></cell>

c) Use the setOnRowSelectHandler method
    grid.setOnRowSelectHandler(my_func,true);
    function my_func( rowId, cellIndex){
        if (cellIndex==some_index)
            confirmDelete("some")
    }

d) create a custom excell


If necessary I can provide a sample.
Answer posted by Joachim Kathmann on Oct 22, 2007 05:11
Thank you for your answer!
Meantime I figured out how to use the "img" celltype with a link on the image. Seems not being documented. I just found it mentioned that img in cells can have an optional link, and in celltype link description it's stated that link parameters use a "^" as delimiter so I tried that with the img definition and it worked. So my button definition is something like:

'images/ico_edit.gif^Edit^index.php?op=edit^_self'

img url^alt text^link url^link target

Please add that to the docs.

Greetings
J. Kathmann