Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Udaya on Jun 04, 2008 23:02
open dhtmlx forum
Onclick of link open a javascript method from XML

Hi,
iam using the DHTMLX grid which has a column type as link.What i want to do is to call a javascript method onclick of that column value,which in turn opens a pop up window.
1.Can you please tell me how to invoke a javascript method onclick of that value
2.How to infer that in the XML(holds the content of the grid)
3.How to pass that link value to the same javascript method



With Regards,
Udaya.R
Answer posted by Support on Jun 05, 2008 01:47
There are two way
a) encode action directly in link value
    <cell>Label^javascript:myCustomCode('Label')^_self</cell>

b) use onRowSelect method of grid ( basically it will be called on each click inside the grid )

    <cell>Label</cell>
    ...
    grid.attachEvent("onRowSelect",function(id,ind){
          if (ind == index_of_link_column)
             myCustomCode(id,ind); // by knowing ID and ind any info related to cell can be retrieved
          return true;
    })
Answer posted by udaya on Jun 05, 2008 03:05

I tried this method..but the thing is iam dynamically writing the XML from a java class,storing the entire data as a string and accessing that from a jsp.This is where iam initializing my grid and want to invoke a js method called

function openManageScreen(elem)

{alert(elem);}

Iam writing the XML as

<cell>100"^javascript:openManageScreen('100')^self</cell>

Can you please guide me.

the error i get is teling like - openManageScreen is not defined

Answer posted by Support on Jun 05, 2008 05:35
The correct XML would be 
    <cell>100"^javascript:openManageScreen("100")^_self</cell>

a) double quotes instead of single ones ( sorry for misleading example in original answer )
b) the _self instead of self
Answer posted by Support on Jun 05, 2008 05:36

Attachments (1)