Page 1 of 1

Is it possible to nest datagrids?

Posted: Sat Oct 31, 2009 9:56 pm
by sturgis
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!

Posted: Sun Nov 01, 2009 11:18 am
by Janschenkel
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.

Posted: Sun Nov 01, 2009 12:09 pm
by malte
And I would love it to be possible too. :)

Posted: Sun Nov 01, 2009 3:12 pm
by sturgis
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!

Posted: Mon Nov 02, 2009 3:54 pm
by trevordevore
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.

Re:

Posted: Sat Oct 30, 2021 10:17 am
by Monox18
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.

Re: Is it possible to nest datagrids?

Posted: Sat Oct 30, 2021 5:09 pm
by FourthWorld
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.

Re: Is it possible to nest datagrids?

Posted: Sat Oct 30, 2021 5:15 pm
by stam
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?

Re: Is it possible to nest datagrids?

Posted: Sat Oct 30, 2021 5:31 pm
by FourthWorld
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.

Re: Is it possible to nest datagrids?

Posted: Sat Oct 30, 2021 6:04 pm
by Monox18
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 4496 times

Re: Is it possible to nest datagrids?

Posted: Sat Oct 30, 2021 7:10 pm
by FourthWorld
Excellent solution.