iOS CustomTableCell List issues

Greetings,

I did a project based on the sample project from the Xojo samples and I ended up with a pretty good result, but recently I discovered that I cannot rely on the list itself because while It scrolls the checkbox moves alone like crazy randomly so I have no idea why and it seems that I cannot even properly update that list because it changes the status alone while scrolling.

Any idea why and how should I handle grouped lists while scrolling ? I will try to make a movie showing the issue and maybe that will help

Thanks

So , here you can clearly say what I`m talking about , you see that all the list is empty, no checkbox checked, then I tick the 1st one on the top , scroll down and on the way I get randomly checked boxes and when running back to the top the box is not checked anymore .

Any ideas ?

Thanks .

@Aurelian Negrea I haven’t watched your video but the iOSCustomTableCell is re-used — when one scrolls out of the view it can be re-used and reappear as a new one scrolling into the view. So you cannot rely on the values of the UI controls in the CustomTableCell — you need to save these values and reload them. Also the values will not be reset to default values once the CustomTableCell is re-used; you need to do that too. So in the RowData method, you should be supplying data for things like checkboxes each time.

Gosh,

Thanks Jason, that seems to be my issue, so I`ll have to try to find a way to do this . This case is for iOSCustomTableCell or for the iOSTable in general ? as I try to see how I can wrap this to make it properly working.

Thanks

[quote=366258:@Jean-Paul Devulder]hi,

try made very simple example and post here, can be a bug in your code or in xojo framework ?

with example, we can test and see we can reproduce this.[/quote]
Hi Jean-Paul,

I cannot guaranty but I will try to do something so I can have this as sample.

Thanks.

Any idea how I can handle the best way this ? currently I`m handling the data in some classes so I was thinking once something was added and edited to save it directly in that class and once I push the content to save it to database directly, in this way I always have the data if you said that it resets always,

Any other ideas ?

Thanks.

As Jason suggested above you have to populate the data into the cells with the RowData method of the iOSTableDataSource interface. To do this you have to implement the interface for your view with the iOSTable.

Unless forced to do otherwise, I always use a data source and it’s always worked well, custom cells or not. I keep the data in an array. Most problems around tables I’ve seen in these forums is when trying to store data in the table cells themselves.

Well this is what I do as well, I use datasource , and use the RowData to populate but it seems that somehow it goes nuts and as Jason T said that might be the issue. so I will try to work with those arrays and each time the data changes on the interface to save it in the array in this way on scrolling and reload the data will be always ok

Thanks.

If you are careful to always set the checkmark to unchecked if it shouldn’t be your issue should go away.

Hello Guys,

So it is very confusing this part with CustomTableCell, Specially the part where you load the data, you scroll the data and you actually edit and save the data.

I see in all the samples that I found on the XOJO Sample applications that usually to edit data you open another view where you actually save it and then go back to the list, what you can do in my case where I do need to edit on the same view where I have the list ? Any ideas ?

I will try to make a small sample project where I put all so I can show the code maybe I`m doing it wrong but I don’t see anywhere handling data cell and editing/saving that part the only doc that I found was editing that means deleting the record and that’s it.

Attached is a part of the snapshot on one of the inventory list. can somebody give me an idea on how to edit the fields .

So the part that I have to edit in this case are the check boxes I have to check it or not and the comment if any, the rest are staying .

the way how I`m loading the data is on the Activate action of the view and trough a method that loads data in 2 classes one for Sections and one for the item itself. but as Jason says it seems that the rows are reused so that causes the data to rewrite the cells creating the scroll.

Another way I was thinking to have an in memory db and once I select the data from the database to load it in that temporary db / table and to edit it directly there and once done to save it in the main database as a final record.

Any other ideas ?

Thanks a lot .

@Aurelian Negrea

For inline editing or edit in table or what ever any other name how they are calling it today you will need to:

  • When editing is made and completed you need to update data source using custom table cell which is attached to table row and table;

iOS is saving memory by recycling resources aka objects.

This happens since you didn’t update data source which is under GUI (Graphic User Interface), Only what you are doing now via your video is make GUI changes which are not reflected to data source.

So you have to make your middle part of code which read/write data from/to data source.

In other words, you made a cake of couple of different layers and only what you are doing now is scratching top layer of cake but not other parts of cake where reflection also should apply.

[quote=371830:@Bogdan Pavlovic]@Aurelian Negrea

For inline editing or edit in table or what ever any other name how they are calling it today you will need to:

  • When editing is made and completed you need to update data source using custom table cell which is attached to table row and table;

iOS is saving memory by recycling resources aka objects.

This happens since you didn’t update data source which is under GUI (Graphic User Interface), Only what you are doing now via your video is make GUI changes which are not reflected to data source.

So you have to make your middle part of code which read/write data from/to data source.

In other words, you made a cake of couple of different layers and only what you are doing now is scratching top layer of cake but not other parts of cake where reflection also should apply.[/quote]
Well thanks for the info , that was the reason I write here, and your point is ?

and point is to look first examples which comes with Xojo and to understand them. after that you will be able to solve your problem by your self :slight_smile:

What I do in this case:

Add a delegate to CustomCell or DataSource.
Add a property to CustomCell called “callback as DelegateName”
Add a method to Datasource to handle the delegate “Function DelegateMethod…”

In the Datasource RowData method just after creating the cell, I set the appropriate callback:

CustomCell.callback = WeakAdressOf DelegateMethod

And each time something is edited in the custom cell, the callback is invoked and the datasource is update accordingly.

If you share a sample project I can help you if this concept is to complicated to understand at first.

[quote=372020:@JrmieLeroy]What I do in this case:

Add a delegate to CustomCell or DataSource.
Add a property to CustomCell called “callback as DelegateName”
Add a method to Datasource to handle the delegate “Function DelegateMethod…”

In the Datasource RowData method just after creating the cell, I set the appropriate callback:

CustomCell.callback = WeakAdressOf DelegateMethod

And each time something is edited in the custom cell, the callback is invoked and the datasource is update accordingly.

If you share a sample project I can help you if this concept is to complicated to understand at first.[/quote]
Hello Jrmie,

Thanks a lot for help and advices. I managed to make a sample project based on what I need to do and you can find it here Sample Project I`ll have a look on your advices and see what I can do, so far best plan will be your way I guess.

Thanks again.

Hi Aurelian,

Here is the updated project:

http://www.jeremieleroy.com/upload/ccTest_updated.zip

All modifications have a comment with the keyword “JLY”
If you search the project for “JLY” you will find all modifications.

Your custom cell now has a delegate
And a new “callback as delegateName” property. Each time something is changed (checkbox and textfield) it invokes the delegate to update data in the datasource.

Now it is up to you to update your database accordingly.

I also added a module named JLY_Extensions with just one method to hide the selection on Table cells, it looks nicer like that.

[quote=372345:@JrmieLeroy]Hi Aurelian,

Here is the updated project:

http://www.jeremieleroy.com/upload/ccTest_updated.zip

All modifications have a comment with the keyword “JLY”
If you search the project for “JLY” you will find all modifications.

Your custom cell now has a delegate
And a new “callback as delegateName” property. Each time something is changed (checkbox and textfield) it invokes the delegate to update data in the datasource.

Now it is up to you to update your database accordingly.

I also added a module named JLY_Extensions with just one method to hide the selection on Table cells, it looks nicer like that.[/quote]

Thanks a lot Jrmie, I`ll have a look on it and update my project based on that and let you know how it goes .

Thanks again.

[quote=372345:@JrmieLeroy]Hi Aurelian,

Here is the updated project:

http://www.jeremieleroy.com/upload/ccTest_updated.zip

All modifications have a comment with the keyword “JLY”
If you search the project for “JLY” you will find all modifications.

Your custom cell now has a delegate
And a new “callback as delegateName” property. Each time something is changed (checkbox and textfield) it invokes the delegate to update data in the datasource.

Now it is up to you to update your database accordingly.

I also added a module named JLY_Extensions with just one method to hide the selection on Table cells, it looks nicer like that.[/quote]
Hello Jrmie,

So far all ok, any idea how I can make the check boxes unchecked by default ? the whole purpose of this is to be manually checked on each point so we will have to have all empty and disabled.

Thanks again.

I think I did it , I just reversed the paint draw on value

I`ll do more tests and I have to be careful on the value