Topic: Master-Detailed

Dear All MVD fans
I would like to create a master-detailed data view or entry form
Is it possible to select name in a grid and display ALL information in page control

Hope some one could upload an example for all of to learn from it
Best regards to all

2 (edited by mathmathou 2015-12-10 10:49:20)

Re: Master-Detailed

Hello smoustafa,


It is possible yes.


Attached is a project of my own. I stripped all you don't need to keep only the example of what you are looking for :


When you clic a row in the tablegrid on the left, you will see the details on the right.
The database has only 2 records, but that should be enough for you to see smile


Look at the script, it's not very complicated.


Cheers


Mathias

Post's attachments

Attachment icon grid.zip 1.48 mb, 447 downloads since 2015-12-10 

I'm a very good housekeeper !
Each time I get a divorce, I keep the house

Zaza Gabor

Re: Master-Detailed

Hi Smoustafa, Mathmathou, Dmitry,

Normally, you would  use a separate form to show the fields of the record you select in the tablegrid.  But there is nothing to stop you from showing those fields on the same form.

Attached is Mathmathou's example but done without using a script.  (Sorry Mathmathou - I was too lazy to write an example so I stole yours - LOL!).

Hope this helps.

Derek.

Re: Master-Detailed

Sorry - the attachment didn't upload!!  Here it is.

Post's attachments

Attachment icon grid.zip 1.48 mb, 440 downloads since 2015-12-10 

Re: Master-Detailed

Hello Mathmatou, sMustapha and Derek

I same the same project for an application about wild flowers in France.
I use another solution to display informations but result is the same.
But a new flower is entered on another form.
On the same form, I placed a grid listing all items of table flowers and beside a panell
with all fields of the table (including photos of flower and leaf)

Here a piece of my code to display infos I do that because I have many tables joined) :

procedure Accueil_TableGrid1_OnCellClick (Sender: string; ACol, ARow: Integer);
Var  s : String;
begin           
       Accueil.DBImage1.LoadFromDatabase('fleurs', 'photo', Accueil.TableGrid1.dbItemID);
       s := SQLExecute('SELECT Familles.Famille from Fleurs left outer join Familles on Fleurs.id_Familles = Familles.id where Fleurs.id = '+         IntToStr(Accueil.TableGrid1.dbItemID));
     Accueil.Label5.Caption := 'Famille : ' + s;

     s := SQLExecute('SELECT Couleurs.Couleur from Fleurs left outer join Couleurs on Fleurs.id_Couleurs = Couleurs.id where Fleurs.id = '+ IntToStr(Accueil.TableGrid1.dbItemID));
     Accueil.Label6.Caption := 'Couleur : ' + s;.....

and so on (there 28 fields)

And I do same thing behind 

procedure Accueil_TableGrid1_OnKeyDown (Sender: string; var Key: Word; Shift, Alt, Ctrl: boolean);
procedure Accueil_TableGrid1_OnKeyUp (Sender: string; var Key: Word; Shift, Alt, Ctrl: boolean);

with a DoubleBuffered to avoid flicker in the image change.

With Delphi, all is possible

JB

Re: Master-Detailed

smoustafa
Please check out this example:

Post's attachments

Attachment icon Master details grid.zip 9.63 kb, 659 downloads since 2015-12-10 

Dmitry.

7 (edited by mathmathou 2015-12-10 19:50:58)

Re: Master-Detailed

Hello all smile


@Derek and Dmitry


Guys... guys... would you believe me if I told you I was not even aware this was possible without scripting ? Derek's solution with double-clic and Dmitry's with simple clic...


Love you guys... this will spare me a lot of coding smile


We should always choose the simpler solution, shouldn't we smile


Thanks for the tips !!


@smoustafa

now you have plenty of examples smile


@jean

Curious about your dubblebuffer thing smile


Cheers


Mathias

I'm a very good housekeeper !
Each time I get a divorce, I keep the house

Zaza Gabor

Re: Master-Detailed

Good Evening Mathias, Smoustafa, Jean and Dmitry,

@Mathias
It is true that we never know what we don't know - till someone else mentions it!!  Then you think "I wish I'd been aware of that 6 months ago!!"

In case you are interested, I have attached a small project I was working on that does a lot of master / detail work.  This includes doing all of the Adds, Changes, Deletions and Searches just using one form.

The script is messy (!) because users wanted to be able to do as much as possible with keyboard short cuts because it is quicker for them.   So much of the complication is trying to keep focus on the grid, remembering what row you are positioned on etc etc.  If you do not need any of those things and can use the mouse, the script would be quite simple.

Hope it gives you some ideas,

Derek

Post's attachments

Attachment icon cars all on one form.zip 369.58 kb, 459 downloads since 2015-12-10 

Re: Master-Detailed

Thank you Derek for the project.


I'll dissect it as thoroughly as possible to avoid "over-coding" on my future project smile


Cheers


Mathias

I'm a very good housekeeper !
Each time I get a divorce, I keep the house

Zaza Gabor

Re: Master-Detailed

Hello Mathmatou

Form1.DoubleBuffered := True;    //  Pour éviter le scintillement au changement d'image
(To put between Begin ... End. ath the end of coding)

This instruction allows to display an image after another without display jitter when moving between items of a grid
(in my case with ....KeyDown and ...KeyUp).

I have long it used when working with images.

So I asked Dmitry to implement this fonction in MVD. I did it and I thank him for that.

I already used it with Delphi7 but I knew any prancing cause the ParentBackground property of the panlel which contained Images.
This property had to be on False but is never left.  We had to write it manualluy in the code.
I asked Borland about this problem and they told me that there was a bug in property ParentBackground of Panel component.

With MVD, Panel has not such a property, but it works well without jitter. I think Embarcadero (who produces RAD XE3
with which is encoded MVD has fixed this bug.

Thanks

JB



but she never left me