Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Enrico Rinolfi on Sep 03, 2009 05:22
open dhtmlx forum
Grid with link to another grid

I've created a grid with data queried on my mysql database.
i've created after in the first grid a link in rows on particular colum.

My question is:

Can i link it to another grid passing variables in order to make a new query and show other data?
may i need a pro- version or not?

Thank you very much for answer.



Answer posted by dhxSupport on Sep 03, 2009 08:16
You can execute custom function on link click to fill other grid with necessary values:
<cell type="link">Real link^javascript:doSomething()^_self</cell>
function doSomething(){
    // any custom code here
}

Answer posted by Enrico Rinolfi on Sep 04, 2009 00:59
But in case to create another grid in the same page....the function must have all grid dichiaration in the function to let appear second grid only
when a link is selected?

or

I can create 2 grid...the first contain my data with link ...the second only the grid and the data will be populated after
click link in a particular row of principal grid....and how can i passing variables between grids in order to make a specific query?

Is there any sort of function to make all simplest?

thank u


Answer posted by dhxSupport on Sep 04, 2009 03:21
You can initialize grid on the page before calling onclick function. After pressing link you will execute custom code and load data to the second grid:
mygrid2.clearAll();//clear all rows if was loaded before
mygrid2.load(url);//load new rows in grid

If you need to know row id or cell index of the clicked row better to use "onRowSelect" event. This event occurs immediately after a row in the grid was clicked. onRowSelect event passes the following parameters: 
id - id of the clicked row;
ind - index of the clicked cell.
  <script>
  grid.attachEvent("onRowSelect", function(id,ind){});
  </script>



Answer posted by Enrico Rinolfi on Sep 06, 2009 14:05
mmm..good,but,after that...
i need to pass the clicked values into a php server code...get.php in order to make a select query that have to return data filtered by row selected....on mysql database....
Answer posted by dhxSupport on Sep 07, 2009 06:51
There is no inbuilt functionality. You can send custom ajax response after row selecting. Also you can try to use dhtlxDataProcessor which can send rend requests to the server side with information about changed rows. Please find more information here http://dhtmlx.com/dhxdocs/doku.php?id=dhtmlxdataprocessor:toc 
Answer posted by Enrico Rinolfi on Sep 08, 2009 13:40
I've tried to use DataProcessor and the data are correct... anyway i would like to pass for example with php get method
the value of selected row via link field...

something like:

if($res){
    while($row=mysql_fetch_array($res)){
        //create xml tag for grid's row
        echo ("<row id='".$row['emp_number']."'>");
        print("<cell><![CDATA[".$row['employee_id']."]]></cell>");
        print("<cell><![CDATA[".$row['emp_lastname']."]]></cell>");
        print("<cell><![CDATA[".$row['emp_firstname']."]]></cell>");
        print("<cell><![CDATA[".$row['loc_city']."]]></cell>");
        print("<cell>Link^http://mypage.php?myvalue_linked=xxx^_self</cell>");
        print("</row>");
    }

In this way i could retrieve that value to create a second SELECT to mysql in the second grid ( if in the second grid i can retrieve that by get method ) and filter by myvalue_linked.
else via javascript ... no matter...