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
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 .
@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.
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.
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,
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
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.
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 ?
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]
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.