Topic: Simulating TreeView with tGrids

As we do not have much wanted treeview component yet in MVD, I was trying to put together a rough treeview navigation using tGrids.


I have tried to get some ideas and use from one of Derek's sample project, needles to say I've failed. I think I couldn't work out linking correctly.


Please see the attached sample project.

Post's attachments

Attachment icon TreeViewSim 1.zip 14.51 kb, 370 downloads since 2017-12-18 

Adam
God... please help me become the person my dog thinks I am.

Re: Simulating TreeView with tGrids

Hi Adam,
I'm never too sure exactly what people are looking for from a treeview component (or if it differs from a set of hierarchical tablegrids).
Anyway, with that proviso, does the attached help any?  I've not had time to smarten it up or test (and there's not much data in it) it but I think the basics are okay.  I might see if I can think of any other approach if I get some spare time.
Regards,
Derek.

Post's attachments

Attachment icon cities.zip 390.58 kb, 388 downloads since 2017-12-19 

Re: Simulating TreeView with tGrids

Hi Derek,


Thank you very much for the sample project............
Looks like my one cell brain failed me again on linking tables.


Your sample project Cities is almost there. When adding state/county and city, combo boxes shouldn't be there.  If country and state/county are selected on form1 tGrids, app should know in which country and state/county city need to be added to. So user doesn't have to do same thing twice. However, replacing combos with labels informing user where their record will be added is very useful.


I think Treeview is just a single grid that data is arranged in hierarchical fashion. However, treeview offers many features as oppose to using multiple grids IMHO. So, I'm still awaiting eagerly for Dmitry to add treeview component to MVD.

Adam
God... please help me become the person my dog thinks I am.

4 (edited by derek 2017-12-19 01:10:31)

Re: Simulating TreeView with tGrids

Hi Adam,
I've made a change for Form3 so the country is passed through and a change to Form4 so that the country and the state are passed through. 
You also need to remove the parent combobox relationship between combobox2 and combobox1 on Form4.
I didn't originally do it that way not knowing what the requirement was - and I like to keep the coding down to the bare minimum!
With that in mind, rather than use labels to tell the user what the related data is, I'd suggest setting the enabled property all of the comboboxes to 'false'.
Derek.

Post's attachments

Attachment icon cities.zip 383.67 kb, 401 downloads since 2017-12-19 

5 (edited by AD1408 2017-12-19 03:22:06)

Re: Simulating TreeView with tGrids

Hi Derek,


Great stuff.........
Thank you very much...........................
Truly appreciated...................................


See if I'll be able to add a little script for tGrids so that after save focuses on saved and delete next available record.


---------------------
EDIT:

Tried for each table;

procedure Form4_Button1_OnAfterClick (Sender: TObject);
begin
Form1.TableGrid3.dbItemID := Last_Insert_Id();
end;

but couldn't get it working.

Adam
God... please help me become the person my dog thinks I am.

6 (edited by AD1408 2017-12-20 19:33:50)

Re: Simulating TreeView with tGrids

As mentioned on previous post, I have tried to implement cell selection / focus after delete but couldn't get it working fully.


I also added to hide relevant grid etc when there is no data on them.


Please see the attached latest version of the project below:
edit: 20/12/2017 20:24:53 (GMT+1)
My apologies. Wrong version of the project was uploaded. The attachment is updated.

Post's attachments

Attachment icon TreeViewSim 1 cities Derek2 Work2a.zip 74.88 kb, 402 downloads since 2017-12-20 

Adam
God... please help me become the person my dog thinks I am.

Re: Simulating TreeView with tGrids

Hi Adam,
I spent a few minutes trying different approaches but there's no way you'll ever get it to be a 'true' tree structure with multiple levels, visual indenting of sub-records etc. 
It would be a nice feature to have but there are plenty of things with the existing basic tablegrid that I think could be improved upon first.
Anyway, if you play around with some of the grid settings you can at least make it look okay and showing a hierarchy of tablegrids (in this example, to 3 levels) has never been much of a problem.
Derek.

Post's attachments

Attachment icon city 2 icons.zip 434.99 kb, 443 downloads since 2017-12-21 

Re: Simulating TreeView with tGrids

Thank you very much Derek...............................
Your help is truly appreciated..................


Calc field - Record count is very nice addition. I like it. Thanks for that too....


Only thing is missing, which I cannot work out, after save event where saved record is selected and focused.

... but there are plenty of things with the existing basic tablegrid that I think could be improved upon first.

Totally agreed. Table grid is perhaps the most important component of a database application. MVD deserves much better one than what is in use at present.
As far as I know MVD is using unsupported (older) version of NextGrid. At the least it should be updated to new version IMHO. Perhaps new version may clear some bugs and offer additional features. I hope Dmitry will update it very soon.

Adam
God... please help me become the person my dog thinks I am.