View Full Version : List with checkbox selection model type behaviour

25 Oct 2013, 11:49 AM
I am working on a List which I need to add ExtJS checkbox selection model functionality too, at least something similar anyway!

So far I am rendering checkbox images as part of the itemTpl config which are shown as ticked or un-ticked based on a Boolean 'IsSelected' field on my model definition. When a user taps an item, if the event source comes from an IMG tag I just change the image to a ticked checkbox and set the IsSelected field on the record for the item to true, and the reverse if they tap an already 'checked' item again keeping the selection state in the IsSelected field of the record.

I have a checkbox in a toolbar above the list which allows for quick select/de-select all, so on doing a select all action I just set the IsSelected field to true for all records on the store and then call refresh on the list to re-render the items and the correct checkbox states

Whilst this kinda works, it does not perform well with large record sets, I can have as many as 2500 records in the store. I have already tried suspending events on the store before setting the IsSelected value on the records and then resuming store events thereafter as i call refresh on the list manually anyway to try and make the process quicker but I can be waiting a good couple of minutes before the list item checkbox states update.

Sorry there is no code sample here, I can add at a later time but I just wanted to sound out my approach and to know if anyone else out there has faced this and implemented a good solution?

One thing I do find is that my IsSelected values get overwritten if the store is reloaded, I saw the persist config property in the docs for the Field class but setting this to false didn't make any difference, as in keeping whatever was set from item taps before a subsequent store load.


28 Oct 2013, 12:22 PM
The persist config will work for when there is a sync operation and it will determine if that field's value is sent in the request.

You can listen to the beforeload event on the store to cache the selected record ids and reapply on load.

13 Feb 2014, 11:57 AM
Hi parky128,

I've been trying for a few days to implement a list with checkboxes exactly how you have described. I'm new to Sencha Touch 2 and am still trying to wrap my head around it. Would you mind posting the snippets of your code that render and control the checkbox list? Many thanks for any help!!