Is it possible to nest datagrids?

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Is it possible to nest datagrids?

Post by sturgis » Sat Oct 31, 2009 9:56 pm

I was thinking it would be interesting to put a table datagrid into a form datagrid, but am having strange behaviors when I attempt this. Rather than beat my noggin against an impossibility for weeks and weeks, (have tried and failed in all attempts to get this working so far) can someone let me know if it IS possible to nest datagrids?

I've used the following code to build my main data array.

global theDataA

Code: Select all

on mouseUp
put empty into theDataA
   repeat with i = 1 to 50
      put "Label " & i into thedataA[i]["Label"]
      repeat with n = 1 to random(5)
         put "Item " & i & n into thedataA[i][n]["Item"]
         put "Energy " & i & n into theDataA[i][n]["Energy"]
         put "Protein " & i & n into theDataA[i][n]["Protein"]
         put "Fat " & i & n into theDataA[i][n]["Fat"] 
         put "Carbs " & i & n into theDataA[i][n]["Carbs"]        
      end repeat
       
   end repeat
   set the dgData of group "dataForm" to theDataA  
end mouseUp
Then in fillinData I have this simple lines.

Code: Select all

on FillInData tDataA
   set the text of field "Label" of me to tDataA["Label"]
   set the dgData of group "tableGrid" of me to tDataA
end FillInData
This works great to populate the label in the datagrid form with the first line, and then passes the rest of the array to the datagrid table by setting dgData again. Everything is populated correctly, it looks surprisingly good (except for a blank line at the top of the table.. Not sure why thats there yet.)

However, scrollbars seem to break when doing this.

Suggestions?


Thanks!

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Contact:

Post by Janschenkel » Sun Nov 01, 2009 11:18 am

When I asked the datagrid developer (Trevor DeVore) about this around the time of the Rev 3.5 release, his response was "It might work, but I haven't tried it myself." So you're in unknown territory here :-)
That doesn't mean it's impossible, just that the underlying code isn' really built for this.

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Contact:

Post by malte » Sun Nov 01, 2009 12:09 pm

And I would love it to be possible too. :)

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Post by sturgis » Sun Nov 01, 2009 3:12 pm

Hmm ok. I'll keep poking around, if I can figure out ways to make things work reliably I'll post methods and examples.

Thanks for the reply!

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1005
Joined: Sat Apr 08, 2006 3:06 pm
Contact:

Post by trevordevore » Mon Nov 02, 2009 3:54 pm

I don't think you will be able to get nested Data Grids to work. The main issue that comes to mind has to do with nested controls. A Data Grid has controls with certain names that are targeted when rendering rows and columns. If you were to nest Data Grids then the parent Data Grid could possibly draw data into the child Data Grid's control rather than the parent Data Grid's control.

Once the engine allows a custom control to truly hide it's controls from the outside world then nesting becomes more feasible.
Trevor DeVore
ScreenSteps - https://www.screensteps.com

LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder

Monox18
Posts: 118
Joined: Tue Nov 25, 2014 9:48 pm

Re:

Post by Monox18 » Sat Oct 30, 2021 10:17 am

trevordevore wrote:
Mon Nov 02, 2009 3:54 pm
I don't think you will be able to get nested Data Grids to work. The main issue that comes to mind has to do with nested controls. A Data Grid has controls with certain names that are targeted when rendering rows and columns. If you were to nest Data Grids then the parent Data Grid could possibly draw data into the child Data Grid's control rather than the parent Data Grid's control.

Once the engine allows a custom control to truly hide it's controls from the outside world then nesting becomes more feasible.
Is it correct to assume that 12 years later, DG nesting is still not possible in LC? I was trying today to nest a DG table into a DG form. Quickly I found out it doesn't work well. If I understand correctly, since the DG is still a normal LC object, then the same problem persists. However, if the DG were to become a widget (this is now the way the engine allows to truly hide controls from the outside world) then DG nesting would be possible? But then again, attempting to convert thousands of code lines to convert from vanilla object to widget... doubt it will happen anytime.

I suppose the workaround for now is to use a table field rather than a DG table as the nested control in the DG form. I was really hoping to use DG as they are far superior to a simple table field.
Monox
Developing a Cyber Physical System.
https://www.monoxware.com/

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10045
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Is it possible to nest datagrids?

Post by FourthWorld » Sat Oct 30, 2021 5:09 pm

If the interior grid is a table and not a form, it doesn't need to be a DataGrid. Try a list field with tabstops and tabAlign set how you like.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

stam
Posts: 3069
Joined: Sun Jun 04, 2006 9:39 pm

Re: Is it possible to nest datagrids?

Post by stam » Sat Oct 30, 2021 5:15 pm

FourthWorld wrote:
Sat Oct 30, 2021 5:09 pm
If the interior grid is a table and not a form, it doesn't need to be a DataGrid. Try a list field with tabstops and tabAlign set how you like.
Is that also true of DG tables with controls embedded (ie where each column is like a form?)

My understand was that this was not the case, but maybe I’m mistaken?

Or are you referring to a DG table with text-only elements?

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10045
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Is it possible to nest datagrids?

Post by FourthWorld » Sat Oct 30, 2021 5:31 pm

stam wrote:
Sat Oct 30, 2021 5:15 pm
FourthWorld wrote:
Sat Oct 30, 2021 5:09 pm
If the interior grid is a table and not a form, it doesn't need to be a DataGrid. Try a list field with tabstops and tabAlign set how you like.
Is that also true of DG tables with controls embedded (ie where each column is like a form?)
Only if the interior grid is a table and not a form.

Text fields primarily display text. Images are the only objects that can be displayed in LC text fields.

If Sturgis needs a list of forms groups within a single cell of a form group, the DG is still likely overkill. DG shines with long lists of data where the full set of interior controls would create a group taller than about 32 ft. That's a lot of scrolling to ask a user to do anyway, which is part of why so many list displays outside of LC use paging. But inside of a single cell, it's difficult to imagine the user-friendly use case requiring that.

Groups are nestable, and can be cloned as needed within a scrolling group reliably as long as the total formattedHeight is less than 32767 px. Perhaps this UI can be realized with that as the interior grid.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Monox18
Posts: 118
Joined: Tue Nov 25, 2014 9:48 pm

Re: Is it possible to nest datagrids?

Post by Monox18 » Sat Oct 30, 2021 6:04 pm

FourthWorld wrote:
Sat Oct 30, 2021 5:09 pm
If the interior grid is a table and not a form, it doesn't need to be a DataGrid. Try a list field with tabstops and tabAlign set how you like.
That's exactly what I ended doing. I personally don't like fields as tables, as I find their possibilities often limiting. A DG has so much more options so I felt tempted checking out if a DG could be nested into another DG. I didn't do exhaustive tests as I found this post and it makes sense that it won't work anyway, so I quickly discarded this idea.

On the other hand, I simply needed an expandable row with extra detailed data. The Tree widget has the functionality that I want but it is also quite limited. So I decided to do my own by nesting a table field in a form DG. The result is attached below. Quite satisfied. Thanks for the responses!
Tests.png
Tests.png (11.2 KiB) Viewed 4498 times
Monox
Developing a Cyber Physical System.
https://www.monoxware.com/

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10045
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Is it possible to nest datagrids?

Post by FourthWorld » Sat Oct 30, 2021 7:10 pm

Excellent solution.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply