Problem deleting rows in tableview

Hi, your idea is correct and the counter works well as I have done and how you tell me in your last post. But this does not mean that there is an error in “deleteRow” if you can test yourself this small example in the simulator.

First touch on row 3 to remove it and later, when you try to touch on to delete row 2 will also give you an error.

?:0: attempt to index field ‘?’ (a nil value)

stack tracebarck:

   [C]: ?

   ?: in function <?:794>

   (tail call): ?

   c:\users … \ main.lua:22: in function '_onRowTouch’

   ?: in function <?:365>

   ?: in function <?:218>

 

I hope your help

Hi, I’m on Corona SDK 2013.1076 (last public build), on Windows 7.

I would like someone to confirm that this problem is already solved.

thaNKS

Yeah, I saw that you were Starter, so I downloaded 1076 and tried with that version and got the same error.

It seems like there was a bug that was fixed in a later build, as 1093 works without giving any errors.

Many many thank you for your help Ingemar, will wait then to the next public build, but anyway I’m thinking of purchasing a pro license.

Thank you very much again for your time and help.

If you get the Pro licence now before the end of April, you’ll be able to continue to get the Pro licence for the next two years at the reduced price of $349  :). If you wait until May you’ll pay the full price of $599 every year.

ok, thanks for the information, I’ll think about it and take a decision before April 30.

regards

hello good morning, we have acquired the pro license and we are using build 1093.

Following the example of pjavelasco, i have proven to work correctly the “deleteRow” function. But when I delete a row, and after try to add a new row I get an error.

I have taken the example of “pjavelasco” and I inserted a button to add rows:

[lua]-- Import the widget library
local widget = require( “widget” )
local list
local addButton
local listRows = {} – my new table

– Handle row rendering
local function onRowRender( event )
   local row = event.row

   local rowTitle = display.newText( row, "List item " … row.index, 0, 0, native.systemFontBold, 16 )
   rowTitle.x = row.x - ( row.contentWidth * 0.5 ) + ( rowTitle.contentWidth * 0.5 )
   rowTitle.y = row.contentHeight * 0.5
   rowTitle:setTextColor( 0, 0, 0 )

   table.insert(listRows, row.index) – Add the row.index to my table
end

– Handle row touch events
local function onRowTouch( event )
   local phase = event.phase
   local row = event.row
   local found

   if “release” == phase then
      found = table.indexOf(listRows, row.index)
      table.remove(listRows, found) – Delete the row from my table
      list:deleteRow(row.index)
   end
end

– Create a tableView
list = widget.newTableView
   {
   top = 38,
   width = 320, 
   height = 448,
   maskFile = “mask-320x448.png”,
   onRowRender = onRowRender,
   onRowTouch = onRowTouch,
   }

– insert rows into list (tableView widget)
for i = 1, 3 do
   list:insertRow{
      height = 72,
   }
end

local function addRow(event)
   if event.phase == “ended” then
      list:insertRow{
         height = 72,
         }
   end
end

– Create a button for insert new rows
addButton = widget.newButton{
   left = 25,
   top = 5,
   width = 100,
   height = 30,
   label = “Add”,
   onEvent = addRow,
}
[/lua]

In the code above, my modus operandi is as follows:

  1. I eliminate the third row by touch on herself

  2. Pulse the “add” button to insert a new row and I get the following error:

?:0: attempt to perform arithmetic on field ‘contentHeight’ (a nil value) 

stack traceback:

    [C]: ?

  ?:in function <?:812>

  (tail call): ?

  c:…\main.lua: 54 in function '_onEvent’

 …

I hope your help

thanks in advance

Looks like you’ve found a bug.

You can submit a report by using the “Report a bug” link at the top of the page.

I have found one inconvenient bug.

in my case i wanna delete one row from tableview.

while i scroll the list and click delete button ,  it failed and said “Warning: A row cannot be deleted whilst the tableView is scrolling”

But i was not scrolling the tableview! is it possible to delete and scroll at the same time?

However if i touch that tableview once and click delete button again, it success !!

that’s weird!

Owen

Hi

Same problem as you OwenYang :

I got this warning message

Warning: A row cannot be deleted whilst the tableView is scrolling

when I try to delete a row.

Any answer from Corona’s team members?

Thanks

Olivier

Hi @oromanetti,

Which build of Corona are you testing this with? There have been quite a few improvements made to TableView in the past couple weeks, so I’d like to see which build this is occurring in.

Thanks,

Brent

Hi Brent

I use Version 2013.1093 (2013.4.20)

Olivier

Hi @Olivier,

I think this is a small bug in how the “state” of the tableView is being transmitted, but to resolve it quickly, can you submit a test case project which shows it happening? This validates the report and will get it addressed soon.

The submission page is here:

http://developer.coronalabs.com/content/bug-submission

Thanks,

Brent

Hi Brent

Ok, I will do it soon

Olivier

I have submitted a bug report for this as well, strange things happening when deleting single rows, adding rows and deleting all rows. Hopefully this gets a fix soon.

Hi

Same problem as you OwenYang :

I got this warning message

Warning: A row cannot be deleted whilst the tableView is scrolling

when I try to delete a row.

Any answer from Corona’s team members?

Thanks

Olivier

Hi @oromanetti,

Which build of Corona are you testing this with? There have been quite a few improvements made to TableView in the past couple weeks, so I’d like to see which build this is occurring in.

Thanks,

Brent

Hi Brent

I use Version 2013.1093 (2013.4.20)

Olivier

Hi @Olivier,

I think this is a small bug in how the “state” of the tableView is being transmitted, but to resolve it quickly, can you submit a test case project which shows it happening? This validates the report and will get it addressed soon.

The submission page is here:

http://developer.coronalabs.com/content/bug-submission

Thanks,

Brent

Hi Brent

Ok, I will do it soon

Olivier