Search Unity

Table Pro: When Your Data isn't a Game

Discussion in 'Assets and Asset Store' started by slumtrimpet, Aug 15, 2015.

  1. slumtrimpet

    slumtrimpet

    Joined:
    Mar 18, 2014
    Posts:
    372
  2. slumtrimpet

    slumtrimpet

    Joined:
    Mar 18, 2014
    Posts:
    372
    Sorry, no, we don't support that.
     
  3. slumtrimpet

    slumtrimpet

    Joined:
    Mar 18, 2014
    Posts:
    372
    There's nothing built-in but it's fairly easy to implement. You'll need your paging buttons of course and then remember tablepro's data is just a list. So you'll have your 'master' list of data in your code and as pages are accessed you'll just show the proper subset of data from your master list in the tablepro list.
     
  4. slumtrimpet

    slumtrimpet

    Joined:
    Mar 18, 2014
    Posts:
    372
    That DragPanel is from the Unity WIKI (or someplace) and was just included in our samples as a way to test TablePro residing inside a dynamically positioned window. I can't really speak to how well it would function in production and you are probably better of writing or acquiring a better windowing solution.
     
  5. slumtrimpet

    slumtrimpet

    Joined:
    Mar 18, 2014
    Posts:
    372
    I'm sorry, I don't think I'm understanding this question. What do you mean when you say the OnPointerDown method fires when on the edge of an image? I'm happy to look into this if you can help explain.
     
    UnusAutomationSystems likes this.
  6. slumtrimpet

    slumtrimpet

    Joined:
    Mar 18, 2014
    Posts:
    372
    Those callbacks are associated with local methods based on your call to the table.Initialize(...) method. You should see the connection made in that method in the included samples. You can find some documentation here on page 15 (but I recommend the samples to actually see how it works):

    https://docs.google.com/document/d/1DO4cXgBbY76HCWjzqC169os8RzeDVcCu4Ruu12vPEP8/edit
     
  7. King-Kadelfek

    King-Kadelfek

    Joined:
    Mar 8, 2010
    Posts:
    18
    Hello! I am using Table Pro to display data, and I based my code on one of the sample (DataTable.cs). I'm starting the game with the provided canvas, that I hide or show depending of the situation.
    I need to display a new table each time I'm displaying data (sort of a pop up containing data), with different columns. So I use the provided block of code (ResetTable, AddColumn, Initialize, StartRenderEngine, etc) each time I want to display the table.

    The problem is that after a few displays, the game starts to lag, and the lags become heavier as I display new tables.

    Am I supposed to dispose of an existing table before recreating it? What is the correct way to display different tables (with different columns) with the same canvas?

    Thanks in advance for your help.
     
  8. AussieSwissDave

    AussieSwissDave

    Joined:
    Apr 20, 2013
    Posts:
    97
    Hello,

    Thank you for your response!

    I guess what I am struggling with is accessing the table outside of the script you attach locally to the table. I can't see in any of the examples somewhere where an external script references the table and populates it, gets the value/index of the clicked column etc. This is really what I need in order to fit in with the structure of my game.
     
  9. slumtrimpet

    slumtrimpet

    Joined:
    Mar 18, 2014
    Posts:
    372
    Look at the DataTable.cs example, specifically the "redraw" button. Are you sure you are doing the full rebuild process on each iteration in your program? You can click the "redraw" button in the DataTable sample forever and the Unity profiler shows no memory leak or performance decrease.

    Can you PM me a sample project demonstrating this behavior?
     
  10. slumtrimpet

    slumtrimpet

    Joined:
    Mar 18, 2014
    Posts:
    372
    I'm not sure I'm understanding the question so please forgive if I'm being thick here, but you get a reference to the TablePro table just like any other MonoBehavior. In any other script in your project just create a public SLS.Widget.Table variable and drag your other GameObject with the Table MonoBehavior attached to it in the Unity editor. You can get a reference to the table in any location you wish using that method or any of the other standard Unity component search routines.

    If I'm misunderstanding the question and being too simplistic please be patient with me and explain in more detail.
     
  11. King-Kadelfek

    King-Kadelfek

    Joined:
    Mar 8, 2010
    Posts:
    18
    The problem was on my side. I got a very sneaky performance leak, as I added a function in the original code. I took your sample you talked about and changed every line until I found the bug.

    Long story short, each new line in a table added a value to one of my cache, and caused a 0.24 millisecond function to be permanently used each frame in the game. It doesn't seem like a lot, but displaying a 100 lines table represents 100 lines * 0.24 millisecond * 60 frames per second = 1.4 second delay for a 1 second gameplay.

    Removing this function, everything runs fine.
    Thanks for your help!
     
    slumtrimpet likes this.
  12. AussieSwissDave

    AussieSwissDave

    Joined:
    Apr 20, 2013
    Posts:
    97
    Hello,

    Thank you very much for your reply. I managed to get it all going and it's working great! Even wrote my own sorting routine that works for any generic type of data added, and distinguishes (and sorts appropriately) between numbers and strings!

    I have two small formatting questions:

    1) How do you prevent text wrapping over multiple lines? What if I wanted it on for the header, and off for the rows?

    2) How would you suggest having column widths that stay constant relative to each other, but dynamically vary with the width of the table? Maybe I have a name column that I want wide, and then a bunch of number columns that I want to all be equally small. I figured you could scale relative to some overall table width but couldn't get it working.

    Much appreciated!
     
  13. slumtrimpet

    slumtrimpet

    Joined:
    Mar 18, 2014
    Posts:
    372
    Unfortunately, we don't really support either of those things. You have the full source to TablePro though so go to town if you want these specialized layout options. :)
     
  14. UnusAutomationSystems

    UnusAutomationSystems

    Joined:
    Jul 15, 2019
    Posts:
    49
    Hello,

    Please, help me to solve this problem.
    I have a question for "ResizePanel".

    When I try to resize at the edge of left side and at the edge of bottom side, it is perfectly work.
    However, when I try to resize at the edge of right side and at the edge of top side, it works as same as left side or bottoms side.

    normally, when we try to resize somethings, work as below
    drag from left side : drag to right = decrease the size of the panel | drag to left = increase the size of the panel
    drag from right side : drag to right increase the size of the panel | drag to left = decrease the size of the panel

    but, if I use "ResizePanel", work as below
    drag from left side : drag to right = decrease the size of the panel ( normal)
    drag from right side : drag to right = decrease the size of the panel (abnormal)


    *I tried to get the mouse position which calculated by the image's coordinate, the parent object tablepro, to distinguish the edge's side. However, the PointerEventData data always bring worldPosition's coordinate.

    Could you please, let me know how to solve this problem?
    (the point coordinate, I uploaded a simple picture, always (x,y) _ position.x is 1200)
     

    Attached Files:

    • 1.png
      1.png
      File size:
      6.4 KB
      Views:
      387
  15. slumtrimpet

    slumtrimpet

    Joined:
    Mar 18, 2014
    Posts:
    372
    That drag panel sample is purely just meant to demonstrate how TablePro behaves inside of a dynamic recttransform parent. The actual coding of the dynamic recttransform parent object is outside of the scope of what we can support in this asset as (we are just the table, not the parent windowing logic).

    I'd recommend looking at https://github.com/yasirkula/UnityDynamicPanels or one of the similar options on the asset store for 'windowing' solutions in Unity UI.
     
  16. Fab-London

    Fab-London

    Joined:
    Feb 6, 2013
    Posts:
    35
    Hi

    I am having issues where the table does not display (turning square in the middle of the table) unless are resize the window, this happen in the Editor as well as when I build the game.

    code is very simple and comes from one of your example
    Any idea on what is might be?
    problem is seen in unity 2018.4.3f1 and 2018.4.11f1 running on windows 10

    thanks

    Code (CSharp):
    1. using System.Collections;using UnityEngine;
    2.  
    3. namespace SLS.Widgets.Table
    4. {
    5.     public class EyesSyslogTable : MonoBehaviour
    6.     {
    7.  
    8.         private Table table;
    9.  
    10.         void Start()
    11.         {
    12.  
    13.             MakeDefaults.Set();
    14.             this.table = this.GetComponent<Table>();
    15.  
    16.             this.table.ResetTable();
    17.  
    18.             this.table.AddTextColumn("Time", "Time");
    19.             this.table.AddTextColumn("Device Name", "Device Name");
    20.             this.table.AddTextColumn("Severity", "Severity");
    21.             this.table.AddTextColumn("Message", "Message");
    22.             this.table.AddTextColumn("Count last hour", "Count last hour");
    23.  
    24.             this.table.Initialize();
    25.  
    26.             // Populate Your Rows (obviously this would be real data here)
    27.             for (int i = 0; i < 100; i++)
    28.             {
    29.                 this.table.data.Add(this.MakeDatum("INIT"));
    30.             }
    31.  
    32.             // Draw Your Table
    33.             this.table.StartRenderEngine();
    34.  
    35.             //this.StartCoroutine(this.DoRandomData());
    36.  
    37.         }
    38.  
    39.         private Datum MakeDatum(string pfx)
    40.         {
    41.             string sfx = Time.realtimeSinceStartup.ToString();
    42.             Datum d = Datum.Body(sfx);
    43.             d.elements.Add("Col1:" + pfx + ":" + sfx);
    44.             d.elements.Add("Col2:" + pfx + ":" + sfx);
    45.             d.elements.Add("Col3:" + pfx + ":" + sfx);
    46.             d.elements.Add("Col4:" + pfx + ":" + sfx);
    47.             d.elements.Add("Col5:" + pfx + ":" + sfx);
    48.             return d;
    49.         }
    50.  
    51.     }
    52. }
     
  17. slumtrimpet

    slumtrimpet

    Joined:
    Mar 18, 2014
    Posts:
    372
    Parts of TablePro rely on coroutines to maintain various things. It sounds like perhaps you are running your code on an inactive GameObject or one on who's active state toggles. Make sure you call the above table initialization code on a GameObject that is active and remains active and then re-call the code if you need to toggle parent object active state.
     
  18. Fab-London

    Fab-London

    Joined:
    Feb 6, 2013
    Posts:
    35
    Hi,

    Thanks for your reply, sorry but I was focusing on something else.

    You are correct the table is nested in a tree of object and I making the root object (RootObject) active or inactive when I want to hide or make visible the table.
    RootObject -> Canvas -> TableObject

    I am not sure I understand the requirement, I have tried to move the code to onEnable but I am still having issues. After a few success switch (around 3) the columns do not resize to the required width and I am also getting some Datum UID collision messages.

    I have tried to clear the data in the table (this.table.data.Clear();) but that does not seem to make a difference.

    Could you provide some highlevel code structure to explain what is required to be able to switch on and off the table.
    Thinking it might also make sense to use the method "OnDisable" as well to clear things ?

    something like
    Code (CSharp):
    1. void OnStart()
    2. {
    3. Resettable();
    4. AddTextColumn
    5. TableInitialize
    6. add the data
    7. StartRenderEngine
    8. }
    9.  
    10. void OnEnable()
    11. {
    12. Table.data.clear();
    13. Table.AddTextColumn
    14. Table.data.Add
    15.  
    16. }
     
    Last edited: Oct 31, 2019
  19. slumtrimpet

    slumtrimpet

    Joined:
    Mar 18, 2014
    Posts:
    372

    For better or worse, the safest thing to do is to actually rebuild the table each time it becomes visible.

    So the trick is to call the stuff in 'Start' in 'OnEnable' after the table has been visible for the first time. (that's because of the [IMO] kinda silly way OnEnable is called BEFORE Start on the first activation of a GameObject and you can't start Coroutines in it then, but then it CAN trigger Coroutines in subsequent activations)

    So here's a hackish way to accomplish that based on the "Simple" demo scene included in the package:

    Code (CSharp):
    1.  
    2.     void Start() {
    3.  
    4.       MakeDefaults.Set();
    5.  
    6.       this.table = this.GetComponent<Table>();
    7.  
    8.       this.table.ResetTable();
    9.  
    10.       this.table.AddTextColumn("Column1");
    11.       this.table.AddTextColumn("Column2");
    12.       this.table.AddTextColumn("Column3");
    13.  
    14.       this.table.Initialize(this.OnTableSelected);
    15.  
    16.       for(int i = 0; i < ROWS; i++) {
    17.         Datum d = Datum.Body(i.ToString());
    18.         d.elements.Add("Col1:Row" + i.ToString());
    19.         d.elements[0].color = new Color(0, .5f, 0.8f);
    20.         d.elements[0].backgroundColor = new Color(0.2f, 0, 0);
    21.         d.elements.Add("Col2:Row" + i.ToString());
    22.         d.elements.Add("Col3:Row" + i.ToString());
    23.         if (i == 2) {
    24.           for(int j = 0; j < d.elements.Count; j++) {
    25.             d.elements[j].color = Color.black;
    26.             d.elements[j].backgroundColor = Color.cyan;
    27.           }
    28.         }
    29.         this.table.data.Add(d);
    30.       }
    31.  
    32.       this.table.StartRenderEngine();
    33.     }
    34.  
    35.     void OnEnable() {
    36.       if(this.table != null)
    37.         this.Start();
    38.     }
    39.  
    Hope that helps!
     
  20. Fab-London

    Fab-London

    Joined:
    Feb 6, 2013
    Posts:
    35
    Thanks for your reply but unfortunately there is still an issue. I understand the performance is not going to be the best but I more worried about achieving the right effect at the moment.

    It works a couple of time. It will display the table correctly the first time the Gameobject tree is enable, the tabled is disabled and I reenable the Gameobject tree where the table is and it is still fine.
    The third time the width of the column is broken, no error messages are seen. (please see screen capture)
    Capture_3rd_switch.PNG
    The 4th time getting the red square in the top left corner and the turning grey square in the middle and with the error message attached.
    Capture_4th_switch_error.PNG Capture_4th_switch.PNG
    This is my code
    Code (CSharp):
    1.        private Table table;
    2.  
    3.         void Start()
    4.         {
    5.  
    6.             MakeDefaults.Set();
    7.             this.table = this.GetComponent<Table>();
    8.  
    9.             this.table.ResetTable();
    10.  
    11.             this.table.AddTextColumn("Time", "Time");
    12.             this.table.AddTextColumn("Device Name", "Device Name");
    13.             this.table.AddTextColumn("Severity", "Severity");
    14.             this.table.AddTextColumn("Message", "Message");
    15.             this.table.AddTextColumn("Count last hour", "Count last hour");
    16.  
    17.             this.table.Initialize();
    18.  
    19.             // Populate Your Rows (obviously this would be real data here)
    20.             for (int i = 0; i < 100; i++)
    21.             {
    22.                 this.table.data.Add(this.MakeDatum("INIT"));
    23.             }
    24.  
    25.             // Draw Your Table
    26.             this.table.StartRenderEngine();
    27.  
    28.             //this.StartCoroutine(this.DoRandomData());
    29.  
    30.         }
    31.  
    32.         private Datum MakeDatum(string pfx)
    33.         {
    34.             string sfx = Time.realtimeSinceStartup.ToString();
    35.             Datum d = Datum.Body(sfx);
    36.             d.elements.Add("Col1:" + pfx + ":" + sfx);
    37.             d.elements.Add("Col2:" + pfx + ":" + sfx);
    38.             d.elements.Add("Col3:" + pfx + ":" + sfx);
    39.             d.elements.Add("Col4:" + pfx + ":" + sfx);
    40.             d.elements.Add("Col5:" + pfx + ":" + sfx);
    41.             return d;
    42.         }
    43.  
    44.         private void OnEnable()
    45.         {
    46.             if (this.table != null)
    47.                 this.Start();
    48.         }
     
  21. slumtrimpet

    slumtrimpet

    Joined:
    Mar 18, 2014
    Posts:
    372

    The error is the UID collision. You are populating the UID with
    Code (CSharp):
    1. Time.realtimeSinceStartup.ToString();
    which is only resolving to four decimal places per your error screenshot there. Your code is looping so fast that realtimeSinceStartup is the same value on two iterations of that population script.

    That also explains why it's intermittent because your PC isn't ALWAYS fast enough to create a collision there, but sometimes it is... I think.
     
  22. Fab-London

    Fab-London

    Joined:
    Feb 6, 2013
    Posts:
    35
    Ok thanks that makes sense, I have replaced the Time.realtimeSinceStartup with and integer that I increment at each iterations. I can not see the error anymore but the other issue with the red square in the top left corner is still present. This seems to get fixed every time I resize the window but on the next switch off and on the same problem is back. Do you have an API/method that could simulate the resize of the table ?

    Thanks
     
  23. slumtrimpet

    slumtrimpet

    Joined:
    Mar 18, 2014
    Posts:
    372
    I have no idea where you are getting a red box from. ;-) Hundreds of people using TablePro and this is the first I've heard of that one but... if resizing the table seems to fix it why don't you try to edit Table.cs in the TablePro folder and make the "RedrawTable" method on line 967ish 'public'. Then see if calling that manually from your code resolves the issue. Let me know if that works.
     
  24. Fab-London

    Fab-London

    Joined:
    Feb 6, 2013
    Posts:
    35
    Hi,

    Thanks for not giving up on my issue, I have tried what you suggested that does not make any difference.
    On my windows machine I do see the top left red box but on my MacBook the problem is slightly different, the columns do not resize correctly. Although an issue is seen on both platform, interesting to see that it does not show exactly the same way.

    I did a small video that might help you understand what I mean, I hope you can see it.



    I am running the same versions of Unity on both platforms, 2018.4.11f1. Did you try to switch on and off the root canvas of table pro in your setup ? wondering if the problem might be with Unity and which version you are running.
     
  25. slumtrimpet

    slumtrimpet

    Joined:
    Mar 18, 2014
    Posts:
    372
    Man... I can't reproduce this. I pulled the same version of Unity as well. Can you give me steps to reproduce the issue in any of the included TablePro sample scenes or (I hate to ask this as I know it's usually a pain) can you roll up and PM a link to a scene that reproduces the issue?
     
  26. Fab-London

    Fab-London

    Joined:
    Feb 6, 2013
    Posts:
    35
    Hi,
    I will try to reproduce it in a new project and make it available for you to download. what do you mean by roll up and PM ?
    Are you on windows or mac ?

    I did a bit more testing and noticed something interesting that might give you an idea where the problem is.
    I noticed that when I see the problem the TablePro->Body->Sizer Heigh is zero and when I resize the window it goes back to the value it should be for the table to show correctly which for my screen is 1200.
    A similar problem exist with the Footer and Header where the Right offset should be around -1494 but when the problem exist it is -52, this is the same problem for the Footer and header.
    I was hoping that it might be due to the root transform I have for the table, I am applying a top offset to 35 pixel so the table can not expend to the full hight of its root game object. I changed the structure to avoid that but that does not seem to help
    Give me a fee days for the repro, worse case I will do it on the coming weekend, Thanks
     
  27. slumtrimpet

    slumtrimpet

    Joined:
    Mar 18, 2014
    Posts:
    372
    "roll up and PM" means package a unity project (export via unity or just zip it up) and 'private message' me a link to dropbox/google drive/etc wherever you stick it for me to pull from. :)

    Thanks
     
  28. All_American

    All_American

    Joined:
    Oct 14, 2011
    Posts:
    1,528
    Before I purchase this, would it be easy to connect SQL database data to this?
     
  29. slumtrimpet

    slumtrimpet

    Joined:
    Mar 18, 2014
    Posts:
    372
    You populate data in TablePro somewhat similar to populating a C# List. Getting the data from SQL or any other data source into C# is on you, but once it's on C# it's easy to put into TablePro. We don't offer any SQL-specific support.
     
  30. All_American

    All_American

    Joined:
    Oct 14, 2011
    Posts:
    1,528
    I have the data in Unity I just need to display it now.

    I'll keep you posted.
     
  31. All_American

    All_American

    Joined:
    Oct 14, 2011
    Posts:
    1,528
    You example shows the table populating all the cells in all the columns with the same cell# all the way down. I can't find in your documentation on how to just do one row at a time.
     
  32. slumtrimpet

    slumtrimpet

    Joined:
    Mar 18, 2014
    Posts:
    372
    Oh man... for some reason I didn't receive a notification email from the forum engine about your last message there.
    I apologize for this very late reply...

    This code populates each 'cell' (aka element) in each 'row' (aka datum) in the table:

    Code (CSharp):
    1. for(int i = 0; i < 100; i++) {
    2.       Datum d = Datum.Body(i.ToString());
    3.       d.elements.Add("Col1:Row" + i.ToString());
    4.       d.elements.Add("Col2:Row" + i.ToString());
    5.       d.elements.Add("Col3:Row" + i.ToString());
    6.       this.table.data.Add(d);
    7. }
    It's not populating the same value all the way down, or I'm misunderstanding the question. Please clarify if you are still stumped here.
     
  33. Fab-London

    Fab-London

    Joined:
    Feb 6, 2013
    Posts:
    35
    Hello,

    Do you have a way that when a new row is added at the end of the table for the table to scroll to this last entry so the user does not need to scroll to see the lastest data entry

    thanks
     
  34. slumtrimpet

    slumtrimpet

    Joined:
    Mar 18, 2014
    Posts:
    372
    Use:
    Code (CSharp):
    1. table.DoVertScrollUntilVisible(datum)
    Where datum is a reference to the row you want to scroll to.
     
  35. Fab-London

    Fab-London

    Joined:
    Feb 6, 2013
    Posts:
    35
    Thanks :)
     
  36. Fab-London

    Fab-London

    Joined:
    Feb 6, 2013
    Posts:
    35
    This does not work
    I had to make the method public to make it available, is it the one you mean ?
    public IEnumerator DoVertScrollUntilVisible(Datum d, int focusCellIdx = -1) {
     
  37. Fab-London

    Fab-London

    Joined:
    Feb 6, 2013
    Posts:
    35
    What I mean when I say it does not work after making the method public and writing the code below it does not scroll to the datum I am passing to the method but the line is added to the table

    Code (CSharp):
    1.    
    2.  
    3.         private Table table;
    4.         private int UID=0;
    5.  
    6.        private Datum MakeDatum(EyesMessage Value)
    7.         {
    8.             string sfx = UID.ToString();
    9.             Datum d = Datum.Body(sfx);
    10.             d.elements.Add(Value.dateTime.ToString("dd/MM/yyyy HH:mm:ss.fff", CultureInfo.InvariantCulture));
    11.             d.elements.Add(Value.UniqueName);
    12.             d.elements.Add(Value.Severity.ToString());
    13.             if (Value.Facility_severity_MNEMONIC != null) d.elements.Add(Value.Facility_severity_MNEMONIC);
    14.             else d.elements.Add("");
    15.             if (Value.Message != null) d.elements.Add(Value.Message);
    16.             else d.elements.Add("");
    17.             UID++;
    18.             return d;
    19.         }
    20.      
    21.         public void AddEntry(EyesMessage eyesMessage)
    22.         {
    23.             if (this.table != null)
    24.             {
    25.                 Datum datum = this.MakeDatum(eyesMessage);
    26.                 this.table.data.Add(datum);
    27.                 this.table.DoVertScrollUntilVisible(datum);
    28.             }
    29.         }
    30.  
     
  38. Fab-London

    Fab-London

    Joined:
    Feb 6, 2013
    Posts:
    35
    It is working now just realised that it needed to put down a Coroutine

    This works
    Code (CSharp):
    1.    
    2.  
    3.         private Table table;
    4.         private int UID=0;
    5.  
    6.        private Datum MakeDatum(EyesMessage Value)
    7.         {
    8.             string sfx = UID.ToString();
    9.             Datum d = Datum.Body(sfx);
    10.             d.elements.Add(Value.dateTime.ToString("dd/MM/yyyy HH:mm:ss.fff", CultureInfo.InvariantCulture));
    11.             d.elements.Add(Value.UniqueName);
    12.             d.elements.Add(Value.Severity.ToString());
    13.             if (Value.Facility_severity_MNEMONIC != null) d.elements.Add(Value.Facility_severity_MNEMONIC);
    14.             else d.elements.Add("");
    15.             if (Value.Message != null) d.elements.Add(Value.Message);
    16.             else d.elements.Add("");
    17.             UID++;
    18.             return d;
    19.         }
    20.    
    21.         public void AddEntry(EyesMessage eyesMessage)
    22.         {
    23.             if (this.table != null)
    24.             {
    25.                 Datum datum = this.MakeDatum(eyesMessage);
    26.                 this.table.data.Add(datum);
    27.                 StartCoroutine(this.table.DoVertScrollUntilVisible(datum));
    28.             }
    29.         }
    30.  
     
  39. slumtrimpet

    slumtrimpet

    Joined:
    Mar 18, 2014
    Posts:
    372
    Ah sorry about the public/private issue. I didn't even notice that when I sent you those directions. I've updated the code in our main repo so future releases will have that method marked as public so you won't have to worry about updates breaking your stuff.

    Thannks
     
  40. JuanMaldonado

    JuanMaldonado

    Joined:
    Oct 12, 2012
    Posts:
    30
    Hi @slumtrimpet
    Is there a way to freeze columns? I need to leave visible the first 2 columns when scrolling horizontally.

    Cheers!
     
  41. slumtrimpet

    slumtrimpet

    Joined:
    Mar 18, 2014
    Posts:
    372
    Unfortunately, no.
     
  42. JuanMaldonado

    JuanMaldonado

    Joined:
    Oct 12, 2012
    Posts:
    30
    @slumtrimpet
    Couldn't figure out how to deselect a row with the Table.SetDeselected
    Could you please show me an example?
     
  43. slumtrimpet

    slumtrimpet

    Joined:
    Mar 18, 2014
    Posts:
    372
    Check out the Samples/Simple scene and Simple.cs code.

    Code (CSharp):
    1.  
    2. public void HandleClearSelectionClick() {
    3.   this.table.lastSelectedDatum = null;
    4. }
    5.  
     
    JuanMaldonado likes this.
  44. AussieSwissDave

    AussieSwissDave

    Joined:
    Apr 20, 2013
    Posts:
    97
    Really enjoying this still. I have a small question:

    I find that when loading a table for the first time it can be a little slow. That's fine for the first time, but I have a very data-heavy game and will have the player flipping through table after table getting repopulated with new information.

    I have created code such that if the table is yet to be created (beenCreated boolean variable) I do a this.table.data.add(dataToAdd[ii]), where dataToAdd is a list of datums. On the other hand, if the table has already been created then I do a this.table.data[ii].elements = dataToAdd[ii].elements.

    I am aware that this requires the number of elements in the table to never change which is fine.

    I have found that this works well and makes things much faster. Instead of re-creating the table each time the data changes you can just change the values of the rows.

    My issue though is I find that if I have let's say a table already populated, and I press a button and it gets re-populated, nothing actually changes until I scroll down the table a couple of rows. It's as if some update/refresh routine has to be run to make the changed data show up. I'm wondering what this is and if you can please point me in the right direction.
     
  45. AussieSwissDave

    AussieSwissDave

    Joined:
    Apr 20, 2013
    Posts:
    97
    Hmmm it seems like the issues actually occur when the amount of data changes. I have added code to try to deal with cases of the updated data having more or less than the existing data. I think that the data does get created properly ultimately, but there is the issue that it is not shown until the table gets scrolled a little.

    On the other hand, if the amount of data stays the same then it refreshes automatically.
     
  46. slumtrimpet

    slumtrimpet

    Joined:
    Mar 18, 2014
    Posts:
    372
    Interesting question. If you look at the declaration of our TableDatumList (aka table.data) and our DatumElementList (aka the .elements attr on any individual Datum) you see we SHOULD capture changing data or changing elements of data instantly... I THINK the issue is that Rather than doing things like:

    Code (CSharp):
    1. this.table.data[ii].elements = dataToAdd[ii].elements
    You need to swap data object or individual elements on existing datum themselves.

    We'd need a setter on the elements attr to capture you swapping the entire object with another and we don't currently have that. It could be added easy enough but let's see if you can just do something like this instead:

    Code (CSharp):
    1. this.table.data[ii] = dataToAdd[ii]
     
  47. AussieSwissDave

    AussieSwissDave

    Joined:
    Apr 20, 2013
    Posts:
    97
    Thank you very much for your reply. I just implemented your quick fix suggestion and it does and doesn't work.

    It works in the sense that the list is now properly updated, regardless of if we move from a list to one that has more, less or the same amount of data.

    However the issue is that the processing time which I had gotten rid of is now back, causing some lag. Dealing with ~50 rows and about 10 columns. Nothing crazy but creating the table for the first time and repopulating it using your method does have a maybe half second lag, whereas my ...elements = ...elements method re-populates the table pretty much instantaneously (but with this updating issue sometimes).

    I suppose that when doing data[ii] = dataToAdd[ii] you are setting more parameters and that takes processing time, but when doing data[ii].elements = dataToAdd[ii].elements it's just changing the minimal, like just the text in the table, so it's much quicker.

    I tried making it such I now loop through elements and individually replace each data[ii].elements[jj].value. This works and has like a mid-level speed in between the previous two solutions. This is the basic code before. I think this is what I'll go for for now.

    Code (CSharp):
    1.             // Add in the data
    2.             DateTime before = DateTime.Now;
    3.             int numColumns = this.table.columns.Count;
    4.             for (int ii = 0; ii <= numRowsToAdd - 1; ii++)
    5.             {
    6.                 if (beenCreated == false)
    7.                 {
    8.                     this.table.data.Add(dataToAdd[ii]);
    9.                 } else {
    10.                     // By default we would like to just replace the elements, but if there aren't enough elements there originally, we will have to create a new one
    11.                     if (ii < numRowsExisting)
    12.                     {
    13.                        
    14.                         // replace all elements one by one: // In between speed that's okay
    15.                         for (int jj = 0; jj <= numColumns-1;jj++)
    16.                         {
    17.                             this.table.data[ii].elements[jj].value = dataToAdd[ii].elements[jj].value;
    18.                         }
    19.                         //this.table.data[ii].elements = dataToAdd[ii].elements; // quickest but has auto update issues
    20.                         //this.table.data[ii] = dataToAdd[ii]; // slowest
    21.                     } else {
    22.                         this.table.data.Add(dataToAdd[ii]);
    23.                     }
    24.                 }
    25.             }
    One thing I am thinking... when I do the .elements = .elements method, i.e. the fastest but with refresh issues, it DOES refresh whenever a vertical scroll happens to the point that one row element has moved outside of the scroll mask. At this point the text for the data element changes when scrolling, i.e. TablePro/Body/Sizer/RowX/CanvasGroup/ColumnY/0text

    I think that whatever function it is that calls to have that updated when a data row scrolls out of the mask, THAT is the update function which I would love to be able to call manually when I change the data. I think that would fix everything.

    Thank you again so much for your help!
     
  48. AussieSwissDave

    AussieSwissDave

    Joined:
    Apr 20, 2013
    Posts:
    97
    I think I have the above figured out now. I am wondering about another thing. Are you able to please tell me where the sorting happens? I can't quite find it in the script. I want to make a few changes to it.
     
  49. swProdBdk

    swProdBdk

    Joined:
    Apr 22, 2020
    Posts:
    10
    I have made a table that can be "filtered" by input through an InputField. If the result on my search is exactly 1 the table doesn't render according to the "fill minimum 100% of space available", but just fill minimum space. Any result with more rows it renders nice as it should.

    The image sort of shows the two different situations.


    The only difference is the number of rows. After a search I reset. table.ResetTable(); - setup columns and initialize -table.Initialize() the same way regardless of the number of rows. I populate after the setup

    The code for filtering is for some reason either deemed "spam-like" or inappropriate here so I uploaded an image of it. see Code.PNG

    Code (CSharp):
    1.  
    2. private void PopulateTable(List<Datum> datumList)
    3.     {
    4.         foreach (Datum datumObject in datumList)
    5.         {
    6.             table.data.Add(datumObject);
    7.         }
    8.        
    9.         table.StartRenderEngine();
    10.     } [/I]
    11.  
    12. [I]




    Any idea of what could cause this behavior?

     

    Attached Files:

    Last edited: May 5, 2020
  50. skytow2003

    skytow2003

    Joined:
    Feb 9, 2014
    Posts:
    30
    Hi.
    Can somebody help me with this. My table randomly displays in the way I have set it up (first photo) and sometime the text is black. It is totally random and I cannot figure out why. table_greyedout.JPG table_ok.JPG