B4A Library [Class] Flexible Table

Discussion in 'Additional libraries, classes and official updates' started by melamoud, Jun 30, 2013.

  1. ardillaprogramadora

    ardillaprogramadora Member Licensed User

    thanks klaus now it works perfectly!
  2. luciano deri

    luciano deri Active Member Licensed User

    Hello, i'am using v 1.44, on a panel on a HorizontalScrollView because i need show some page with more table.
    The problem is that HSV consume horizontal swipe event, so table not scroll. But some times, when swiping is diagonal the table scroll. How can i solve it?
    (The swipe on header table can is priority on HSW?)
  3. klaus

    klaus Expert Licensed User

    You cannot use the TableView in a HorizontalScrollView.
    Why do you use a HorizontalScrollView?
    The TableView scrolls in both directions!
  4. luciano deri

    luciano deri Active Member Licensed User

  5. klaus

    klaus Expert Licensed User

    Unfortunately, the TableView in a HorizontalScrollView will not work.
    Because HorizontalScrollView consumes the scrolling event.
  6. luciano deri

    luciano deri Active Member Licensed User

    How can i add a sub in Table class to return a event when begin or end swipe touch?
    I could try to disable HSW when scroll table and enable when table stop.
  7. klaus

    klaus Expert Licensed User

    I have nerver tried this, don't know if this will work.
    The internal object is a ScrollView2D.
    It has a ScrollingIsFinished method.
    Perhaps you could use this in the SV_ScrollChanged event routine to raise an event when scrolling is finished.
  8. Turbo3

    Turbo3 Active Member Licensed User

    What is the purpose of the -/+30 in the ScrollChanged routine which is used to set the currentMin/currentMax?

    My users have reported that not all rows of their data are being displayed when I use "Table". The data is loaded from a csv file. I have tracked the problem down to the -/+ 30 preventing the ShowRow routine from being called. If I remove the -/+ 30 offset all the rows are displayed. So why is it there?

    Private Sub SV_ScrollChanged(PosX As Int, PosY As Int)
    Dim currentMin, currentMax As Int
        currentMin = 
    Max(0, PosY / cRowHeight - 30)
        currentMax = 
    Min(Data.Size - 1, (PosY + SV.Height) / cRowHeight + 30)
  9. LucaMs

    LucaMs Expert Licensed User

    Also, 30 without dip has no-sense.
  10. Turbo3

    Turbo3 Active Member Licensed User

    PosY/cRowHeight should give top row number and the other bottom row number on screen but then why the 30 row offset for both?
  11. klaus

    klaus Expert Licensed User

    It is intendet to limit the number of rows in the scrollview before updating.
    Not all rows are added in the scrollview, the rows outsides the given range are dynamically removed and reloaded.
    The demo program in the first post loads a Table from a csv file and all rows are shown, so I don't understand why it doesn't in your case.
    Can you post a small project showing the problem so I can investigate what happens.

    The 30 without dip is normal !
    The value represents an index of a row not a dimension!
    LucaMs likes this.
  12. Turbo3

    Turbo3 Active Member Licensed User

    In my case the problem is that the load cvs only displays the first 23 rows (of the 39 rows read in) as that is all that fits on the screen (Addrow limits that). Only the scroll change routine can display the others and you have blocked that with an offset of 30.

    Here is the AddRow code.
    If lastRow < (SV.VerticalScrollPosition + SV.Height) / cRowHeight + 1 Then
    End If

        SV.Panel.Height = Data.Size * cRowHeight
    Last edited: Mar 17, 2018
  13. klaus

    klaus Expert Licensed User

    Are you sure that bottom part of the scrollview is not hidden by another view or outsides the screen ?
    Without seeing your project it is impossible to give a concrete advice.
    As already said, the demo program shows all rows, therefore I cannot reproduce the problem.
  14. Turbo3

    Turbo3 Active Member Licensed User

    I will make up a little demo and post but it is 1 AM here so I will work on it in the morning. But here is the image my user sent me showing the problem when he scrolls down. The bottom should be filled with data but is not. If I remove the "30"s it works.

    Log statements show that ShowRow is never called again after the first set of row is loaded.

  15. klaus

    klaus Expert Licensed User

    You need to be patient, I will be absent till tomorrow afternoon.
    It's 9 o'clock AM here.
    In the test project ship also your csv file.
  16. Turbo3

    Turbo3 Active Member Licensed User

    I did a quick test with your latest example code and my user's data and it works. I can scroll down through all his data

    However, Log statements show it works because maxVisibleRow is always -1 whereas in my code it is the actual last visible row of 21. It is 21 because that is what fit on the screen when the cvs was first read in.

    The question now is why does the example code use -1 when it should use 3 which is all that fits in the much smaller example code window.

    More to look at tomorrow. But I should be able to figure this out now.
  17. Turbo3

    Turbo3 Active Member Licensed User

    After a lot of tracing with Log statements finally found the problem. It is due to Erel's new Resumable Sub feature and my code not being updated to comment out a Sleep(0) statement to prevent the subroutine from being turn into a Resumable.

    The table example has the fix for this but my app, which was written years ago and has the Table.bas code that was available at that time, did not have it. I don't actually see the fix listed in the Table version history but is probably mentioned somewhere in the 40 pages of the thread.

    In my code the innerClearAll sub was marked as Resumable which was causing parts of it to be executed after the first part of the table was loaded. That caused maxVisibleRow, which had been set correctly, to be cleared.

    The fix was to comment out two lines to match the Table example that removed the Sleep(0) statement which is what turned innerClearAll into Resumable. The innerClearAll routine should be executed to the end before any other routines are executed.
  18. Inman

    Inman Well-Known Member Licensed User

    Is it possible to change background colors of certain rows? In my table, the rows are like grouped into sections. So it will be like:


    I am looking for a way to highlight these section headers so that user knows where a section begins and ends. Is it possible?
  19. palmzac

    palmzac Active Member Licensed User


    I want to freeze column 1. Is it possible ? Thanks !
  20. klaus

    klaus Expert Licensed User

    Sorry, it is not possible.
    The only rowcolors are odd and even rows.

    Sorry, it is not possible.
  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