B4i Library [class] Table

Discussion in 'iOS Libraries' started by Erel, Nov 6, 2014.

Thread Status:
Not open for further replies.
  1. Erel

    Erel Administrator Staff Member Licensed User

    Attached Files:

    Last edited: Dec 30, 2014
    Johan Hormaza likes this.
  2. fishwolf

    fishwolf Active Member Licensed User

    I use this module with success, but when i enter the second time into page with table, the design table is corrupt.

    In this case i had add a table to ThreePage example (note to top a part of table)

    Code:
    Public Sub ShowModule
       
    If pg.IsInitialized = False Then
         pg.Initialize(
    "pg")
         pg.RootPanel.LoadLayout(
    "ColorsLayout")
         
    Dim items As List
         items.Initialize
         
    For Each clr As String In clrs.Keys
           
    Dim s As AttributedString
           s.Initialize(clr, 
    Font.DEFAULT, clrs.Get(clr))
           items.Add(s)
         
    Next
         Picker1.SetItems(
    0, items)
       
    End If
       Main.NavControl.ShowPage(pg)
       btnChoose.Color = GetSelectedColor
       
       TableResults.Initialize(Me, 
    "TableResults"7)
       TableResults.AddToParent(pg.RootPanel, 
    050%y100%x50%y)
       TableResults.SetHeader(
    Array As String("Data""Prove""Arr""Tp""E/R""Pen""Qual"))
       
       
    For i = 0 To 100
         TableResults.AddRow(
    Array As String("Row: " & i, "ccc""ddd""eee""ccc""ddd""eee"))
       
    Next
       
    End Sub
     

    Attached Files:

    • foto.PNG
      foto.PNG
      File size:
      172.7 KB
      Views:
      183
  3. Turbo3

    Turbo3 Active Member Licensed User

    How hard is it to add the ability to scroll left/right to display a large table (wide) like the B4A version?
     
    Last edited: Dec 27, 2014
  4. klaus

    klaus Expert Licensed User

    Here you are.
    Attached version 1.11
    Added horizontal scrolling.
    Added Left, Top, Width, Height, Visible properties
    Added LoadTableFromCSV2(Dir As String, Filename As String, HeadersExist As Boolean, SeparatorChar As String, AutomaticWidths As Boolean)

    EDIT: 2015.10.13 version 1.12
    Amended errror reported HERE.
     

    Attached Files:

    Last edited: Oct 13, 2015
    Erel likes this.
  5. Turbo3

    Turbo3 Active Member Licensed User

    Thanks. However, there is corruption when you change orientation. I would add "SV.Bounces=False" to Initialize() in Table to keep the data from separating from the header when you hit the limits.
     
  6. klaus

    klaus Expert Licensed User

    1) Screen orientation OK, it was not a problem in the class but how I added the TableViews.
    2) The data is no more separated from the header during bouncing.
    3) Added the Bounces property.
    I updated the file in post#4, I left the version number V1.10.
     
    moster67 likes this.
  7. fishwolf

    fishwolf Active Member Licensed User

    also with the new vesion the design table is corrupt when enter the second times into ColorsModule

    attach the project:
     

    Attached Files:

  8. klaus

    klaus Expert Licensed User

    The problem is not the class.
    The problem is in your code !
    Every time you show ColorsModule you add a new Table !?
    You must move the code adding the Table in the IsInitialized part of the code:
    Code:
    Public Sub ShowModule
        
    If pg.IsInitialized = False Then
            pg.Initialize(
    "pg")
            pg.RootPanel.LoadLayout(
    "ColorsLayout")
            
    Dim items As List
            items.Initialize
            
    For Each clr As String In clrs.Keys
                
    Dim s As AttributedString
                s.Initialize(clr, 
    Font.DEFAULT, clrs.Get(clr))
                items.Add(s)
            
    Next
            Picker1.SetItems(
    0, items)

            TableResults.Initialize(Me, 
    "TableResults"7)
            TableResults.AddToParent(pg.RootPanel, 
    050%y100%x50%y)
            TableResults.SetHeader(
    Array As String("Data""Prove""Arr""Tp""E/R""Pen""Qual"))
         
            
    For i = 0 To 100
                TableResults.AddRow(
    Array As String("Row: " & i, "ccc""ddd""eee""ccc""ddd""eee"))
            
    Next
        
    End If
        Main.NavControl.ShowPage(pg)
        btnChoose.Color = GetSelectedColor
    End Sub
     
    Last edited: Feb 26, 2015
    Erel likes this.
  9. fishwolf

    fishwolf Active Member Licensed User

    Thanks
    i was sure that the problem is into my code :)

    sorry, i have modify the code and work fine

    but if i add a second table into other page the problem return
     

    Attached Files:

  10. Turbo3

    Turbo3 Active Member Licensed User

    I added the following code to ThreePages as suggested above to allow orientation change re-sizing.
    Code:
    Private Sub pg_Resize (Width As Int, Height As Int)
        TableResults.Top =
    50%y
        TableResults.Height=
    45%y
        TableResults.Width =
    100%x
    End Sub
    However, this introduces a side effect that does not allow you to scroll and see the last line. You can see it while you have your finger scrolling but as soon as you remove your finger row 100 goes off screen and the last row you see is 99. If you don't have bounce enabled you can't see row 100 at all.

    Is this a code problem in ThreePages or in Tables or is there more that needs to be added to the Resize code I added?
     
    Last edited: Dec 29, 2014
  11. Erel

    Erel Administrator Staff Member Licensed User

    Can you upload your project?
     
  12. Turbo3

    Turbo3 Active Member Licensed User

    Here is a modified version of ThreePages that includes the re-size code that then results in not being able to keep Row 100 visible.

    I use an iPhone 4 so I need to start the program in landscape mode to have the first column display the row numbers.

    I am starting to think it is a bug in ScrollView.

    Have a look and see what the problem is.

    If you disable bounce then you will never be able to see row 100. But comment out the pg_resize code and row 100 is back.
     

    Attached Files:

    Last edited: Dec 30, 2014
  13. Erel

    Erel Administrator Staff Member Licensed User

    I've uploaded a new version of TableView (v1.01). I've added a Resize method which you can call in Page_Resize event to correctly resize the table.
     
  14. Turbo3

    Turbo3 Active Member Licensed User

    That only fixes it for the original orientation (landscape in my test). When I switch to portrait I can now only scroll down to row 98. Also the resize did not really work in portrait as the window size stayed the same with the same number of rows visible as in landscape instead of showing more rows on the taller screen.

    Please add this new Resize to the test code I uploaded and try changing the orientation.

    If you think it works then post the modified code so I can see how you did it.
     
  15. klaus

    klaus Expert Licensed User

    Attached you find a working version.
    It removes and regenerates the table in the Resize routine.
    The Table class has new peoperies: RemoveFromParentView and IsInitialized.

    PS: For the last entry not displayed was due to an error, in the Height property change (in the class version in post#4).
     

    Attached Files:

  16. Turbo3

    Turbo3 Active Member Licensed User

    klaus, Perfect. Thank you very much.
     
  17. fishwolf

    fishwolf Active Member Licensed User

    with versione 1.01 i have the same problem with 2 tables into 2 pagse, the second table is corrupt only if i show the first.

    i suppose that 2 instance have some data shared or i use bad :)

    attach the project
     

    Attached Files:

  18. klaus

    klaus Expert Licensed User

    Attached your project working.
    It's the same solution as in post #15.
     

    Attached Files:

    fishwolf likes this.
  19. tufanv

    tufanv Expert Licensed User

    I am using 1.1 version of Klaus. I can add rows to table 1
    but in another panel i initialized table2 I can see the headers but cant add any rows ( it doesnt show the rows whereas table1 shows its rows )
    ( ı checked the coloumn number of table 2 and addrow event they have the same number but still no luck
    )
     
  20. tufanv

    tufanv Expert Licensed User

    I realized that there is a problem with height of the table
    table1.AddToparent(panelnewaircraft, 0, 40dip, 100%x, 150%y) altough this is the code, i can only see 1 line with 100%y i cant see anthing. Where is the mistake on my side =?
     
Thread Status:
Not open for further replies.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice