View Full Version : Detail datagrid...?

08-09-2010, 01:23 AM
Hi everyone, first post, and have looked all over the place for some help on this. So hopefully someone has an idea as to what exactly im looking for.

I picked up FB4, and have been playing around with the data services and php. I have a MYSQL database with 2 tables, one is clients, the other is properties.

In FB4 I have successfully connected to the database and have bound the "getall" clients service to a datagrid control. Now im looking to get a second datagrid that will display the properties that are associated with each client.

My properties table has a foreign key, and I can run a join command succefully on the db. so... i was thinkning doing something like modifing the get all property service with my custom query, and then calling the service from:

dataGrid2.addEventListener(ListEvent.ITEM_CLICK,on ItemClick);

but, how does the second datagrid know which client I am on??

What is the proper way to work with multi tables and a master detail style grids??

best regards,

08-09-2010, 02:17 AM
ok, well I figured it out. Quite simple actually. after hours and hours of searching for a sample, a walk through, or someone just mentioning the usage of a freaking datagrid, I trouble shot myself through success.

for anyone following me in this endeavor: connect to your first table as a service, then connect to your second table as a service. Drag a 2 datagrid components onto the canvas. bind the get all service call to your first datagrid as normal. Then on the second datagrid, (in my case its "properties") bind the getall properties by ID. This is designed for a integer return type.

now... when you do this it opens the mxml code window and wants you to insert a value for your ID to be returned. simply point to the first datagrid and the key column. Now, copy that line of code, flip over to design view, generate an event change, and paste that code into that function. Done! now every time you click on a record, it will display the corresponding table data.

protected function clientdg_changeHandler(event:ListEvent):void
getPropertiesByIDResult.token = propertiesService.getPropertiesByID(clientdg.selec tedItem.id);

take care.