Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Christopher Maxwell on Jul 16, 2008 06:50
open dhtmlx forum
Subgrids displayed by row

I am trying to use your subgrid to display two tables in my database that have related data. What i want to do is have the subgrid be specific to the row that is selected. The two tables that I am using have id's in common, so i want to be able to just display the row in my second table that corresponds to the id in the first table when the subgrid is displayed. I don't want to display the whole table every time the subgrid is displayed. Is there any way that I can do this?
Answer posted by Support on Jul 16, 2008 07:50
Technically it possible by using some kind of filterBy functionality against sub-grid, so it will show only necessary rows.
But in such usecase , the more simple solution would be to have two grids , with onRowSelect event attached to the frist one. When user selects record in first grid, onRowSelect event fires and you can show any necessary info in second grid.
Answer posted by Christopher Maxwell on Jul 16, 2008 08:06
Well what I want to be able to do is that when the second grid is displayed, I want the user to be able to edit the data in both grids and be able to save those changes.  I just don't want to display the related data; i want the user to be able to make changes to both tables at the same time.  Will the onRowSelected function accomplish this task?
Answer posted by Support on Jul 17, 2008 05:53
This will work as well.
In case of recommended solution, the second grid is a separate grid instance , which can work as normal grid. So you can save data from it in any possible way.
Please check attached sample.
Attachments (1)
Answer posted by Christopher Maxwell on Jul 17, 2008 08:05
Is there any way to display the second subgrid by matching it up with an id in the first grid.  For instance, the two tables that I am trying to present have there id's in common.  In the second table, there is a column called portal_id which corresponds to the id in the first table.   Is there anyway to do the onRowSelected function by a column in my table rather than doing it by the id and having multiple xml files that corresponds to the id of the grid.  I was looking at your example and saw that you had three separate xml files for all of the individual sub grids. Is there anyway that I can avoid making multiple xml files for each individual row because if I have to do it this way, i will have to generate a whole lot of xml files for each individual row.  Is there any way to do this or is generating multiple the xml files my only option?
Answer posted by Support on Jul 17, 2008 09:34
The attached sample uses static XML, but common approach is use dynamic server side script, so you will have in event code
    grid.loadXML("some.php?id="+id)
so related grid will be filled with data based on selected row in master grid.
In such case you will need any static files at all, server side script will fetch necessary info rom DB and will output it as XML.

It also possible to implement similar behavior by filtering - please check attached sample.


Attachments (1)
384798.ZIP91.11 Kb