Topic: Creating Treeview like panel with new entries and groups

Hello,

Can this be done with MVD?

Add a treeview to create and select entries,
then auto-display previously filled form fields when selecting treeview entries.

Adding new entries.

Create groups.

Filter groups from the form data.

Here is a 3 minutes Youtube ID of the reference video.
o6wqnpdtFQg

0:10 Clicking treeview entries / auto-display in form
0:31 Creating new entries / filling the form
1:02 Creating Groups
1:19 Filtering groups using form data
1:40 default / pre-made data in database

Thank you for your insights.

Re: Creating Treeview like panel with new entries and groups

Youtube reference not working

3 (edited by franklabre 2024-01-05 05:00:07)

Re: Creating Treeview like panel with new entries and groups

tcoton wrote:

Youtube reference not working

Hello,
This forum doesn't let me post images.

Please test this Youtube ID:
/watch?v=o6wqnpdtFQg

It goes after the youtube.com
Thank you.

Re: Creating Treeview like panel with new entries and groups

Hi,
The problem is that 'Persona' does things (and appears very good) in a way that obviously play to its strengths and so MVD (and any other piece of software) will almost inevitably not compare as favourably. 
It also means that you run the risk of ignoring the strengths of MVD by only trying to mirror the way that 'Persona' works and not considering different approaches where MVD might be more suited.
So having said that, in principle, much of what you are asking about can be done in MVD using 'treeviews'.
However, my personal opinion is that 'treeview' functionality has some limitations (you can't easily drag and drop nodes, you can't by default re-sort nodes etc/  It can be done but just not 'out of the box' and you would need to write script.
My advice would be to mock up a small scale project in MVD using 'treeviews' and see exactly where you think it might come up short.  Then post back to the Forum (attaching your project) and contributors might be able to suggest not only how to overcome any 'treeview' specific problems you may have encountered but also suggest wholly different approaches (linked tablegrids comes immediately to mind) that might be more suitable to MVD.
Regards,
Derek.

Re: Creating Treeview like panel with new entries and groups

Hi Derek,
Many thanks for your reply and insights.
I am slowly but surly rebuilding a similar dataset from the app for later testing.

Couple questions about MVD if I may. I found the user guide at:
myvisualdatabase.com/download/Book_My_Visual_Database.pdf

Is it the latest available release of the manual? I can't find any reference to the treeview in the pdf.
Is there some other resource you could kindly point to for this purpose?

That's interesting you pointed the nodes drag and drop feature as I wondered as well why it was used by the app.
For now I shouldn't really need that feature, it would suffice having a way to filter the records into groups using tags, but if possible more as with the form format of the app rather than a grid, mainly because it would be more convenient for data entry purposes.

Also I see there is a mention of the need of separate forms with MVD for data entry and data search functionalities. Would it be is possible to combine the two functionalities into a single form as with the app?

Many thanks again for you advice and remarks.

Regards,
Frank

Re: Creating Treeview like panel with new entries and groups

Hi,
In one of the user guides, there are some references to 'treeview' but it's along the lines of 'this is what it is' rather than how to create a project using it..  I've always found it better to use this Forum's search function, look at the various posts and download projects that are of interest and use them as a guide (but I guess we all 'learn' differently).
Wit regard to using separate forms, 'standard' MVD takes the approach of one form to list the data (which can also be used for 'searches') and a second form for data maintenance.  However, it is possible to use the same form for both functions if you write a small script.
On a more general note, I should point out that MVD is no longer under active development and support for the software is solely via this Forum.  But if you submit detailed questions that are accompanied, if possible, by a project that illustrates the problem, you will almost always get a speedy response;  questions along the lines of the  "....I can't see my data.  What's wrong?' variety tend to, understandably, not get much of a response - big_smile
Regards,
Derek.

7 (edited by franklabre 2024-01-08 07:22:28)

Re: Creating Treeview like panel with new entries and groups

Hi Derek,
Thanks a lot for the good suggestions and combining forms remarks.
About the idea you suggested of taking a look at other similar treeview projects, do you know of such projects I should be looking at to get up and running?
I just found about this online guide:
myvisualdatabase.com/help_en/TreeView1.html
It is quite detailed. I'll study it and be back asap with the data.
Regards,
Frank

Re: Creating Treeview like panel with new entries and groups

Hello Derek, Hello franklabre

I created several projects with the MVD TreeView component (between us, it's not great, the Delphi 7 one is better, but it has the merit of existing).
The documentation concerning the TreeView is very brief and as Derek says, it is on the forum that you will find a lot of information on this subject.
Take a close look at what we can do with TV (here my library) and which would be in line with what you want to achieve.
Good luck
JB

Post's attachments

Attachment icon Bibli1.jpg 96.66 kb, 16 downloads since 2024-01-08 

Re: Creating Treeview like panel with new entries and groups

Hi jean, where did you find the icons in your attached screenshot?

Re: Creating Treeview like panel with new entries and groups

Hi Frank, Jean, TCoton,
I couldn't find any examples on the Forum of a 'treeview' project that does everything on the same form (that you were asking about a couple of days ago) so I knocked up a quick example to show you how it could work (it uses a combination of 'treeview' and 'editable tablegrid').  I'm sure there must be other approaches you could take as well - MVD is pretty flexible.
With the 'editable grid', simple type any changes 'in situ' to data that is already there and to add a new row, use the input line at the very top of the 'editable grid' and then press enter to save.
Obviously if it was a 'real' application, you'd want to put some error checking etc in place but it's just for demo purposes so I wanted to keep it relatively 'code free'.
Hope this helps,
Derek.

Post's attachments

Attachment icon treeview music.zip 440.45 kb, 69 downloads since 2024-01-09 

Re: Creating Treeview like panel with new entries and groups

franklabre wrote:

Hello,

Can this be done with MVD?

Add a treeview to create and select entries,
then auto-display previously filled form fields when selecting treeview entries.

Adding new entries.

Create groups.

Filter groups from the form data.

Here is a 3 minutes Youtube ID of the reference video.
o6wqnpdtFQg

0:10 Clicking treeview entries / auto-display in form
0:31 Creating new entries / filling the form
1:02 Creating Groups
1:19 Filtering groups using form data
1:40 default / pre-made data in database

Thank you for your insights.

https://youtu.be/o6wqnpdtFQg

I am sure that all this can be done at the MVDB. But scripts will be required to implement functions such as displaying data in the work area depending on the selected tree element. Most of all you will have to tinker with the mechanism of smart groups, but it can also be implemented. But you need to start not with the interface, but with the data structure. And everything else will follow. ))


There are two implementation options: 1) place all interface elements on one form (use TdbPageControl); 2) use several forms, displaying them on the main form. The first one is easier in the short term, the second one is better in the long term.


But again, you need to start with the data structure.

Визуальное программирование: блог и телеграм-канал.

Re: Creating Treeview like panel with new entries and groups

Hi,

You can try it like this.


Thanks to Derek for starting this.

Post's attachments

Attachment icon treeview music m.zip 335.73 kb, 64 downloads since 2024-01-09 

Re: Creating Treeview like panel with new entries and groups

TCotton:

I simply ask Mr Google: 'icon Find' or 'icon Research', 'icon Spreadsheet' and so on and I choose the one that seems most elegant to me.

Derek:

I'm going to use your example to enter my entire blues collection (nearly 500 CDs). Simply TreeView with performers, tracks and album art. No need for more. Thanks again.

Sparrow:

A nice little addition to Derek's example and all on one form.
I added this instruction to sort the artists alphabetically:
begin
    form1.menu := nil;
    Form1.TreeView1.dbCustomOrderBy := 'ParentID, mname';            // Form1 TV sorting
end.

J.B.

Re: Creating Treeview like panel with new entries and groups

Hi Jean,
The project I posted for user FrankLabre had a few bits taken out to simplify the script so he could see just the things that related to his questions.
If you're going to use it (or some amended version of it), here is the version with some of the functions added back in (colour coding / bold font of nodes and adding counts for the number of tracks on each CD).
Unfortunately, in the script I had to hard-code the checks for the 'parentid' (I should have reset the sequence number back to zero before I started but forgot - my bad!!  sad).
Good Luck - 500 CDs is a lot!!
Derek.

Post's attachments

Attachment icon treeview music 2.zip 442.15 kb, 53 downloads since 2024-01-09 

Re: Creating Treeview like panel with new entries and groups

Hello Derek

It took me a while (a few years) to acquire these CDs.
But I'll probably put less into capturing them in the project.
Between 15 and 20 a day will eventually do it.
J.B.

16 (edited by franklabre 2024-01-10 07:27:39)

Re: Creating Treeview like panel with new entries and groups

Many thanks to everyone for your great insights and contributed scripts!

I've looked and done some tests with Derek's treeview music m.zip script version from sparrow.
Here is my latest modification:
paste.c-net.org/GatherLimited

In summary, I added a GroupBox3 to the form and tried modifying the script
by adding a SQL command to the top level tree node { to execute when clicking the "MUSICIANS" treeview Menu }.

The idea would be to ouptut the Musicians names matching the SQL command inside the
Memo3 field in the GroupBox3, upon clicking the MUSICIANS treeview entry.

I tested the following query which returns a " not enough actual parameters at 38.18" error:
ibb.co/JRmPpZK

         SQLQuery('SELECT mname FROM musicians WHERE musicians.id in (select Alb_info.id_musicians from Alb_info where Alb_info.Year = "1978")');
         { SQLQuery("SELECT musicians.mname FROM musicians, Alb_info WHERE Alb_info.id = '1978' "); }
         { SQLQuery('SELECT id_musicians FROM Alb_info where Alb_info.Year = "1978" ');  }
         { SQLQuery('SELECT * FROM musicians'); }
         Form1.Memo3.Text := Results.FieldByName('mname').AsString;


I also tested the other commented out SQL commands above which return the same error.

I could not find a solution or helpful suggestion online to this issue despite finding some good resources
stackoverflow.com/questions/10829812/sql-query-where-value-of-another-table
codeproject.com/Articles/33052/Visual-Representation-of-SQL-Joins
stackoverflow.com/questions/5446778/select-from-one-table-matching-criteria-in-another

Is there some specific SQL syntax to MVD I'm missing? If so could any one point me toward the relevant documentation on this topic?
Else any suggestion about likely SQL syntax or logic error pointer would be very appreciated.

The SQL command above should return the Musician name according to the
search criteria matching the id_musicians value from both tables,
but based on the corresponding Year field/colum value matching the 1978 value.

RUST NEVER SLEEP should be returned for that example.
ibb.co/XLfCvFH

The idea would be next to expand this query to match any "tag" / string value from a given column/field
to replicate the original project.
And ultimately try to do the same with a second treeview instead of a memo3 field to get the final result
of selectable record from the created groups, if possible.

Many thanks again for your next suggestions!

Regards,
Frank

Re: Creating Treeview like panel with new entries and groups

Hello Sparrow

Based on your excellent project, I tried to add an additional object: the album cover.
In the Alb-Info table, I therefore created an Image field called Covers.
When in the OnExit procedure which saves all the entries, I implement this code:

if (Sender is TdbImage) and (TdbImage(Sender).TagString <> StrToMD5(TdbImage(Sender).Picture))
   then
   begin
     if SQLExecute('SELECT count(id) FROM "'+TdbImage(Sender).dbTable+'" WHERE id_musicians = '+Form1.TreeView1.sqlValue) = '0' then
       SQLExecute('INSERT INTO "'+TdbImage(Sender).dbTable+'" (id_musicians) VALUES('+Form1.TreeView1.sqlValue+')');
       SQLExecute('UPDATE "'+TdbImage(Sender).dbTable+'" SET "'+TdbImage(Sender).dbField+'" = '+TdbImage(Sender).sqlValue+' WHERE id_musicians = '+Form1.TreeView1.sqlValue);
       Form1.Label7.Visible := true;
       TdbImage(Sender).Tag := 0;
       TdbImage(Sender).TagString := '';
       Timer(1000);
   end;

I get an incompatibility message between String and Picture.
I guesse this problème stands here : StrToMD5(TdbImage(Sender).Picture))
There is no way to resolve this anomaly. I ask for your help
How convert String and Picture ?
thanks in advance
Sincerely
J.B.

18 (edited by sparrow 2024-01-10 13:45:43)

Re: Creating Treeview like panel with new entries and groups

Hello Jean

For images you need to use a different path.


I'll try to make an example

Re: Creating Treeview like panel with new entries and groups

Hi Frank

The best tutorial on MVD is this forum.
You are using the "SQLQuery" function and not the "SQLExecute" function. Each of these functions has its own syntax and return data.
The SQL language in MVD is standard for SQLite and MYSQL.

The SQLExecute function is quite simple and is only needed to retrieve one field and one record.
The SQLQuery function allows you to retrieve multiple fields and records.

Re: Creating Treeview like panel with new entries and groups

Salut Jean,
With the program that I use to catalogue my CDs, I don't bother with CD cover images or to capture the lyrics (too much like hard work smile).
But just out of interest, I made a version with CD covers and lyrics just to see how it could be done (I don't use 'treeview' very much and some of the differences between it and the usual tablegrid approach are quite interesting and I need the practice!).
I was trying to do everything without any buttons (a combination of interactive tablegrids, treeview and right-click actions but had to admit defeat with saving the images so there is still one button)!!
Anyway, I've attached it and maybe it helps.
Regards,
Derek.

Post's attachments

Attachment icon treeview music 4.zip 1.84 mb, 52 downloads since 2024-01-11 

21 (edited by franklabre 2024-01-11 09:43:00)

Re: Creating Treeview like panel with new entries and groups

Thanks sparrow and Derek for the solution hints.

I found the SQL Query reference in the guide under the button menu
(which function requires a tablegrid object for displaying the output rather than my previously used memo3):
myvisualdatabase.com/help_en/SQLquery.html
(I had been looking for the SQLQuery documentation using the SQLQuery keyword, which returned nothing, but SQL Query did).

Then got the SQL syntax corrected from this great resource and pointer post:
sqlitetutorial.net/sqlite-subquery/
myvisualdatabase.com/forum/viewtopic.php?pid=45037#p45037

SELECT  mname
FROM musicians
WHERE musicians.id = (
   SELECT id_musicians
   FROM Alb_info
   WHERE Year = '1978'
);  

It now outputs as expected:
ibb.co/D1GTHsr
ibb.co/kQkHRKV
ibb.co/mtGrFzN
ibb.co/p2w9NSf

The latest script:
https://paste.c-net.org/RapportHendrix

Sparrow, you mentioned the use of SQLExecute function.
Is there some way to output the SQL Query result in a Treeview when using a script with the SQLExecute function?
Avoiding the use of a button? I'd like to display the output straight from clicking the "MUSICIANS" menu if possible.
If so, do you know of some sample or example I should be referencing?

Thanks again for your remarks.
Regards,
Frank

Re: Creating Treeview like panel with new entries and groups

Version of the program with image support.
Something like this.

Post's attachments

Attachment icon treevmus with im.zip 734.35 kb, 36 downloads since 2024-01-12 

Re: Creating Treeview like panel with new entries and groups

Hello Frank,

Avoiding the use of a button? I'd like to display the output straight from clicking the "MUSICIANS" menu if possible.

A simple way to 'avoid' the use of a button is to actually still use a button with either the 'search' or the 'sqlquery' function but then hide it. 
Then use the 'incremental search' function (see screen shot in the attachment).  This is a 'no script' option.
Derek.

Post's attachments

Attachment icon frank.zip 512.96 kb, 49 downloads since 2024-01-12 

Re: Creating Treeview like panel with new entries and groups

Hi all,


New mod, Drag and drop images are now supported.

Post's attachments

Attachment icon treevmus with im 1.zip 899.94 kb, 57 downloads since 2024-01-12 

Re: Creating Treeview like panel with new entries and groups

Hi all,

Thanks Derek for that example.

I came that far with my project in attachment:
the project (with the script of interest)
paste.c-net.org/StanleyTower
the db files
paste.c-net.org/ConnellYummy

I'm not sure about how to get  forward with the script as
my database design skills are rudimentary and I doubt the schema is correct but it seems
I can't make more connections as per given by the Persona model.

Could anyone point me toward next recommended steps I should be taking
in order to display the database characters names in the treeview?

I should be able to proceed from there with the tags filtering, likely by using a a 2dn form
as with the Persona model.

Thanks again!