Inserting a table in a tabel cell

Post

Posted
Rating:
#1 (In Topic #914)
Regular
seany is in the usergroup ‘Regular’
 Hi

I am creating an interface to manage my AI training data. I wanted to rapidly prototype it with gambas, version 3.17.5.

I need a tabular display, where I can add / insert subtables in a table cell. That way I want to be able to display some combinatorial graphs connecting various parameters.

Looking at the wiki, I can't find anything. Any help will be appreciated
Online now: No Back to the top

Post

Posted
Rating:
#2
Guru
BruceSteers is in the usergroup ‘Guru’
 Can the cells .Tag property help?
As type variant it can be anything. Then the visible data can be a string representation.

Failing that make an array like TableData As Variant[][]
 that could easily be made to hold data relevant to the current cell at column/row.


Have you tried making a new table with the current cell as it's parent?
Online now: No Back to the top

Post

Posted
Rating:
#3
Regular
seany is in the usergroup ‘Regular’
Hi

Thank you for the reply.

Consider this code snippet, please.

Code (gambas)

  1. Public Sub Button2_Click()
  2.  
  3.  
  4.  
  5.   Dim newTable As New TableView(parentTable.Current) As "Dyntable" 'consider this line especially
  6.   Print "new table is being created"
  7.   Print parentTable.Tag
  8.  
  9.   Dim code As String = ""
  10.   Dim i, j As Integer
  11.  
  12.   For i = 1 To 2
  13.     For j = 1 To 4
  14.       Dim c As String = Chr(Rand(48, 57))
  15.       code = code & c
  16.     Next
  17.     code = code & "-"
  18.   Next
  19.  
  20.   code = code[0, Len(code) - 1]
  21.  
  22.   newTable.Columns.Count = 3
  23.   newTable.Columns[0].Title = "Variable Class (subtable)"
  24.   newTable.Columns[0].Width = newTable.Font.TextWidth(newTable.Columns[0].Title) + 10
  25.   newTable.Columns[1].Text = "ID"
  26.   newTable.Columns[1].Width = newTable.Font.TextWidth(newTable.Columns[1].Title) + 100
  27.   newTable.Columns[2].Text = "DATA"
  28.   newTable.Columns[2].Width = newTable.Font.TextWidth(newTable.Columns[2].Title) + 200
  29.  
  30.   'newTable.Rows.Count = newTable.Rows.Count + 1
  31.  
  32.   newTable.Width = mainArea.Width + 10
  33.   newTable.Height = mainArea.Height - newTable.Top - 5 - 10
  34.   newTable.Resizable = True
  35.   newTable.Header = newTable.Horizontal
  36.  
  37.   newTable.Tag = code
  38.  
  39.   newTable.Resizable = True
  40.  
  41.  
  42.  

Beyond that → consider the image please.

<IMG src="https://i.imgur.com/ktWba7W.png"> </IMG>

Initially, parentTable is set as the form itself. Then I create a new row in the grid view that is visible, by clicking "Create root". I select a cell where i want to insert the subtable, and then click "create leaf". The clicking action sets the available gridview as parent table.

The error is "Type conflict: Expected container, found _Gridview_Cell". So the container plan does not really work

But I will try to work the rest out using tags.
Online now: No Back to the top

Post

Posted
Rating:
#4
Guru
BruceSteers is in the usergroup ‘Guru’
Yes i think a gridview and each cell is more a drawn area in one big outer container and not a bunch of smaller containers that objects can be added to.
Online now: No Back to the top

Post

Posted
Rating:
#5
Regular
seany is in the usergroup ‘Regular’
same thing happens with a table view as well
Online now: No Back to the top

Post

Posted
Rating:
#6
Guru
BruceSteers is in the usergroup ‘Guru’

seany said

same thing happens with a table view as well

Yes a TableView inherits GridView  comp/src/gb.form/.src/TableView.class · master · Gambas / gambas · GitLab

it's essentially just a GridView with added cell editing abilities so apart from the editing it behaves exactly the same as a GridView will.

You could possibly get what you want just by using a ScrollView Arranged Vertically
Then adding Panels containing your TableViews and other data

probably just easiest to use a multi-line string representation and make a popup window to edit if needed
there's always a way :)
Online now: No Back to the top

Post

Posted
Rating:
#7
Regular
seany is in the usergroup ‘Regular’
Hi


So the process continues. I can overlay tables on top of each other, I am still refining the process. Please see image.

<IMG src="https://i.imgur.com/Uv986ky.png"> </IMG>

The table marked with green arrow is the outermost "master". It can be seen that the subtable is marked in red arrow, is well placed in the cell. Ignore the other tables please.

Now, if i click on the cell marked with the blue triangle, sometimes it returns that the

Code

Last
object is the outermost table (which is not correct) and sometimes, it is indeed the subtable marked in red (which is correct, the use of red and green as color markers are not related to correctness. That was arbitrary). Clicking on the column headers results in the same.

How can I ensure to place a particular object at a particular Z index, and ensure that clicking on one editable object will not go through it, activating the object underneath it?

Thank you.
Online now: No Back to the top

Post

Posted
Rating:
#8
Guru
BruceSteers is in the usergroup ‘Guru’
I think you should veer away from the initial object being a TableView

Attached is a simple example of using a scrollview and manually adding panels. I just added a TableView and a VBox with a delete button in it.

But you are free to add whatever you like as normal to each newly added panel.  no TableView/GridView restrictions.

the code is just this…

Code (gambas)

  1. ' Gambas class file
  2.  
  3. Public Sub Form_Open()
  4.  
  5.   ScrollView1.Spacing = True
  6.   ScrollView1.Padding = 2
  7.   ScrollView1.Arrangement = Arrange.Vertical
  8.  
  9.  
  10. Public Sub btnadd_Click()
  11.  
  12.   Dim iCount As Integer = ScrollView1.Children.Count
  13.  
  14.   Dim h As Panel = New Panel(ScrollView1)  ' make a panel
  15.  
  16.   h.Width = ScrollView1.Width
  17.   h.Arrangement = Arrange.Horizontal
  18.  
  19.   With tv = New TableView(h) As "TView"
  20.     .Name = "TView_" & iCount
  21.     .Expand = True
  22.     .Columns.Count = 2
  23.     .Columns[0].Text = "TView_" & iCount
  24.     .Columns[1].Text = "i 2"
  25.     .Header = .Horizontal
  26.     .Mode = Select.Single
  27.  
  28.     Inc .Rows.Count
  29.     tv[.Rows.Max, 0].Text = "oo"
  30.     tv[.Rows.Max, 1].Text = "the data of oo"
  31.  
  32.     Inc .Rows.Count
  33.     tv[.Rows.Max, 0].Text = "aa"
  34.     tv[.Rows.Max, 1].Text = "the data of aa"
  35.  
  36.     h.Height = (.Rows.Height * 2) + Style.FrameWidth + .Columns.Height ' set the tableview height
  37.  
  38.   Dim vb As New VBox(h) ' add some control buttons like delete
  39.   vb.Width = 40
  40.   vb.Spacing = True
  41.   Try vb.Centered = True
  42.   Dim b As New Button(vb) As "btnDel"
  43.   b.AutoResize = True
  44.   b.Picture = Picture["icon:/16/delete"]
  45.   b.Tag = h
  46.  
  47.  
  48. ' the delete button, the buttons .Tag is set to it's containing panel so we  use that to remove the container
  49. Public Sub btnDel_Click()
  50.  
  51.   Dim hb As Panel = Last.Tag
  52.  
  53.   For Each o As Object In hb.Children
  54.     If Object.Type(o) = "VBox" Then o.Children.Clear
  55.     o.Delete
  56.   Next
  57.   hb.Delete
  58.  
  59.  
  60.  

the things being displayed do not make a lot of sense but the point is to show how it could be easier to not use a TableView at the top level due to the restrictions.

With the IDE you could make another form that is the template for each panel and keep adding that to the scrollview.

As for your current issue with your current method i would suggest using unique Names or parenting but i do not know how you are getting the data as you have not explained that so i cannot point out the error.

in my example above i have used the delete buttons .Tag to point to the correct container , i could also have used Last.Parent.Parent in the btnDel_Click() event

Attachment
Online now: No Back to the top

Post

Posted
Rating:
#9
Regular
seany is in the usergroup ‘Regular’
 I still want a way to quickly show that one table is a subtable of another table. I do have a scrollview, containing the main table, which expands or contracts, based on its cell contents, and then i can clearly show that one table is a subtable .

So for example, i can have in the outer table, samples 1 … N, each corresponding to a row. And then (take the example of sample 6) I can show each sample in 3 columns. First column = column 0 is serial num, like 1, 2, … N. The second one is an automatic generated Random key. In the third column (so cellrow = 5, cellcolumn = 3) I can add another table, and then hold param1, … paramK each in a row. Now in this table, each row can have 2 columns, first one ( = index 0) the param Name (such as param1) and the second one the param value. I want to do this in arbitrary depth.

This sort of visualization is needed.  

I will probably also have to add an "expand / collapse" button pair to ensure that the total view does not get out of hand.
Online now: No Back to the top

Post

Posted
Rating:
#10
Regular
seany is in the usergroup ‘Regular’
I can now do this, to arbitrary depth

<IMG src="https://i.imgur.com/paA211R.png"> </IMG>

I want to get rid of the scrollbars in the middle, and make it possible, that

<LIST type="decimal">
  1. <LI>
  2. The subtables move, based on whether an element is added or deleted above it,</LI>

    <LI>
  3. The subtables can be deleted post adding</LI>

    <LI>
  4. The subtables can be expanded and collapsed. Collapse should affect all the other tables that are subtables to it.</LI>
</LIST>

I add the relevant form and class. They are not Fmain.

Any help is appreciated.

Attachment
Online now: No Back to the top
1 guest and 0 members have just viewed this.