B4J Question b4xTable InlineEditing ClearDataView doesnt work?

Aegis

Member
Licensed User
Longtime User
Hello

I'm trying to delete a row from a b4xtable with the inline diting module

I've tried the standard b4xtable code posted by erel https://www.b4x.com/android/forum/threads/b4x-b4xtable-delete-row.103582/#content
I've tried calling DataUpdated afterwards.

But it only works for the first row. The table counters dont update, calling the same instruction twice does nothing (i'd expect, that calling delete row 1 10 times would delete row 1 to 10, as long as i call cleardataview and dataupdated after every delete)

Am i missing something?
 

Aegis

Member
Licensed User
Longtime User
Its just the original example code plus

B4X:
Sub DeleteRow ( RowId As Long)
    B4XTable1.sql1.ExecNonQuery2("DELETE FROM data WHERE rowid = ?", Array (RowId))
    Dim page As Int = B4XTable1.CurrentPage
    Dim FirstIndex As Int = B4XTable1.FirstRowIndex
    B4XTable1.ClearDataView 'Updates the rows count.
    If FirstIndex + 1 >= B4XTable1.mCurrentCount Then
        page = page - 1
    End If
    B4XTable1.CurrentPage = page
End Sub


Private Sub btntestDelete_Click
    Dim whichrow As String = txtfWhere.Text.Trim 'row number to delete
    If IsNumber(whichrow)=False Then Return
    'ie.ExitEditMode
    DeleteRow(whichrow)
    ie.DataUpdated                     'does nothing
    B4XTable1.UpdateTableCounters     'does nothing
    B4XTable1.ClearDataView         'does nothing
    Log("size"&B4XTable1.Size)
End Sub

Pressing the button multiple times does nothing, as the rows dont scale down after the first delete
 

Attachments

  • TestInlineEditB4J.zip
    377.7 KB · Views: 123
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
1. It is not related to the inline editing feature.
2. Your assumption that RowId has any relation with the order of rows and especially with the current visible rows is wrong.

B4X:
If IsNumber(whichrow)=False Or whichrow < 1 Or whichrow > B4XTable1.VisibleRowIds.Size Then Return
Dim RowId As Long = B4XTable1.VisibleRowIds.Get(whichrow - 1)
If RowId = 0 Then Return
ie.ExitEditMode
DeleteRow(RowId)
 
Upvote 0

Aegis

Member
Licensed User
Longtime User
Thanks alot, Works flawlessly! ?

I thought the ids would all scale down after an operation, seems like i was mistaken...
 
Upvote 0
Top