Android Question B4XTable SQL1 - CreateDataView

RB Smissaert

Well-Known Member
Licensed User
Noticed with B4XTable that you can delete rows of the underlying memory table but that there seems to be no way to make this show properly in the table display. So, although the deleted rows don't show any data there still are the same number of rows and also pages.

In the provided example I ran this code at the end of Activity_Create:

B4X:
 'this does delete table rows, but doesn't remove pages or display rows
 B4XTable1.sql1.ExecNonQuery("delete from data where rowid > 100")
 B4XTable1.Refresh
And that demonstrates the problem. I call it a problem as it would be nice if the display could be adjusted
according to the deleted rows.
Is there a way to do that?

Not had a proper look at this (B4XTable) yet, but it seems the table display is only set by .SetData with the provided list. Would it be possible to add the option to set the data directly with SQL and setup the display from the table data rather than from the list? I think this would be very useful.
Or am I overlooking something, and can this be done already?

RBS

 

RB Smissaert

Well-Known Member
Licensed User
Why aren't you using CreateDataView?

B4X:
B4XTable1.CreateDataView("rowid > 100", Null)
CreateDataView has only one parameter in the library I downloaded from the first post.
Is there an updated library somewhere or do I need the files as in the example?

RBS
 

RB Smissaert

Well-Known Member
Licensed User
It should be:
B4X:
B4XTable1.CreateDataView("rowid > 100")
I take it you meant:

B4X:
B4XTable1.CreateDataView("rowid < 101")
But that still shows all 275 pages.
It looks .CreateDataView can work on the underlying memory table, but it doesn't alter the display accordingly.
So how do I adjust the display after altering the memory table?

RBS
 

RB Smissaert

Well-Known Member
Licensed User
This should work for you:
B4X:
Sub btn_Click
    B4XTable1.CreateDataView("rowid < 101") 'show recs from 1 to 100 included  
End Sub
But that still shows 275 pages and the wrong number of rows.
Did you try it in the posted example?

RBS
 

RB Smissaert

Well-Known Member
Licensed User
B4XTable.SetData is an asynchronous method.

Change your code to:
B4X:
B4XTable1.SetData(data)
   Do While B4XTable1.mCurrentCount = 0
       Sleep(50)
   Loop
   B4XTable1.CreateDataView("rowid < 101")
Thanks, that solved the problem.

RBS
 
Top