Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » ArrayCtrl, HeaderCtrl & GridCtrl » GridCtrl: master - detail
GridCtrl: master - detail [message #33641] Sat, 03 September 2011 10:46 Go to next message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
Hello,

is there a similar functionality in GridCtrl?

If not, are there snippet code able to simulate it?

I guess they should be in HomeBudget but the code look complex and I can't find what it is real useful. So some better localization of this part of code would be great.

Thanks,
Luigi
Re: GridCtrl: master - detail [message #33650 is a reply to message #33641] Sat, 03 September 2011 21:58 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

forlano wrote on Sat, 03 September 2011 04:46

Hello,

is there a similar functionality in GridCtrl?

If not, are there snippet code able to simulate it?

I guess they should be in HomeBudget but the code look complex and I can't find what it is real useful. So some better localization of this part of code would be great.

Thanks,
Luigi

GridCtrl has no direct support for master/details functionality. But it's very easy to implement it.
GridCtrl master, details;

master.AddIndex(ID);
master.AddColumn(LIBRARY_NAME, "Library name");
master.WhenRowChange = THISBACK(UpdateDetails);

details.AddColumn(BOOK_NAME, "Book name");

void UpdateDetails()
{
    SQL * Select(ID, BOOK_NAME).From(BOOKS).Where(LIBRARY_ID == master(ID)); //master(ID) returns ID from currently selected row
    while(SQL.Fetch)
        details.Add(SQL[BOOK_NAME]);
}
   


In this example master contains list of libraries and details contains books from selected library. Of course you have to add clearing details grid if new library is added. Is this helpful for you or you needed to know something more complicated?
Re: GridCtrl: master - detail [message #33651 is a reply to message #33650] Sat, 03 September 2011 23:23 Go to previous message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
unodgs wrote on Sat, 03 September 2011 21:58


GridCtrl has no direct support for master/details functionality. But it's very easy to implement it.
GridCtrl master, details;

master.AddIndex(ID);
master.AddColumn(LIBRARY_NAME, "Library name");
master.WhenRowChange = THISBACK(UpdateDetails);

details.AddColumn(BOOK_NAME, "Book name");

void UpdateDetails()
{
    SQL * Select(ID, BOOK_NAME).From(BOOKS).Where(LIBRARY_ID == master(ID)); //master(ID) returns ID from currently selected row
    while(SQL.Fetch)
        details.Add(SQL[BOOK_NAME]);
}
   


In this example master contains list of libraries and details contains books from selected library. Of course you have to add clearing details grid if new library is added. Is this helpful for you or you needed to know something more complicated?



Thanks a lot Daniel,

I needed just this example to feel confident that the work can be done.

Luigi
Previous Topic: GridCtrl/DropGrid problem: Value related.
Next Topic: [SOLVED] ArrayCtrl and German characters
Goto Forum:
  


Current Time: Thu Apr 25 21:38:01 CEST 2024

Total time taken to generate the page: 0.04192 seconds