Results 1 to 5 of 5

Thread: Programmatic List selection change fails until list is shown

    Wait! Looks like we don't have enough information to add this to bug database. Please follow this template bug format.
  1. #1
    Touch Premium Member
    Join Date
    Dec 2010
    Posts
    25

    Default Programmatic List selection change fails until list is shown

    Hi,

    Using Touch 1.1.0.

    I tried to initialize List selected item before and after list's initComponent(), but it fails until the list was displayed at least once. So, expected behavior: selection should work after data is supplied to the list even if the list has not been shown before. After the list was displayed for the first time, selection works alright. FYI, in this particular case the list was on a floating panel. (I tried to work around the problem by trying to do initial list selection not until its parent panel 'activate' event was risen, but it appears that another bug got in the way: activate event does not seem to be fired for a floating panel.)

    Here's the code:

    Code:
    function SelectListItem(list, itemIndex) {
    
        //try {
            if (itemIndex >= list.store.data.length)
                return;
    
            var selModel = list.getSelectionModel();
            selModel.select(itemIndex);      // <<<<<<<< FAILS HERE
    //    }
    //    catch (ex) {
    //        console.log(ex);
    //    }
    }
    Here's the exception stack:


    1. Uncaught TypeError: Cannot call method 'addCls' of null
    1. Ext.DataView.Ext.extend.onItemSelect sencha-touch-debug.js:22967
    2. Ext.DataViewSelectionModel.Ext.extend.onSelectChange sencha-touch-debug.js:22477
    3. Ext.AbstractStoreSelectionModel.Ext.extend.doMultiSelect sencha-touch-debug.js:22206
    4. Ext.AbstractStoreSelectionModel.Ext.extend.doSelect sencha-touch-debug.js:22176
    5. Ext.AbstractStoreSelectionModel.Ext.extend.select sencha-touch-debug.js:22157
    6. SelectListItem TouchMain.js:248
    7. Views.WorkOrderDetailView.Ext.extend.onActivatedWorkOrderDetailView.js:131
    8. firesencha-touch-debug.js:979
    9. Ext.util.Observable.Ext.extend.fireEventsencha-touch-debug.js:595
    10. Ext.Anim.run.aftersencha-touch-debug.js:29733
    11. Ext.Anim.Ext.extend.onTransitionEndsencha-touch-debug.js:13426
    12. anonymous:5
    13. (anonymous function)sencha-touch-debug.js:4428

    Thank you,
    Vlad.

  2. #2
    Sencha User jep's Avatar
    Join Date
    Sep 2010
    Posts
    862

    Default

    I ran into this same issue. Is this another thread that slipped through the cracks recently?

  3. #3
    Sencha - Engineering Operations mike.estes's Avatar
    Join Date
    Mar 2011
    Location
    Redwood City, CA
    Posts
    221

    Default

    try this override that makes onItemSelect a little more cautious:

    Code:
    Ext.override(Ext.DataView, {
        onItemSelect: function(record) {
            var node = this.getNode(record);
            var node_el = Ext.get(node)
            if (node_el) {
                node_el.addCls(this.selectedItemCls);
            }
        }
    });
    this seems to work in my tests, can you confirm?

  4. #4
    Sencha User
    Join Date
    Aug 2010
    Posts
    35

    Default Same here

    I have the same problem. Tried Mike's solution - didn't work (no TypeError after calling select but whole selection went nuts - first row selected even when tapping on others). Any thoughts?

  5. #5

    Default

    I select records in data grid (TouchGridPanel plugin) and that workaround works fine!
    Yet another workaround to my collection. I wonder how I will migrate to ST2 with all thouse workarounds and bux fixes....

    btw, you should also fix "onItemDeselect" in the same way to avoid errors.

    Code:
    onItemDeselect: function(record) {
        var node = this.getNode(record);
        var node_el = Ext.get(node)
            if (node_el) {
                node_el.removeCls(this.selectedItemCls);
            }    
    },

Similar Threads

  1. Listen for Selection and De-selection in the List componet
    By porticue in forum Sencha Touch 1.x: Discussion
    Replies: 3
    Last Post: 1 Dec 2010, 2:01 AM
  2. List after rotating to landscape only partly shown
    By torsten.t in forum Sencha Touch 1.x: Discussion
    Replies: 2
    Last Post: 18 Nov 2010, 1:14 AM
  3. Shuttle list or dual selection pick list
    By Whatty in forum Ext 3.x: Help & Discussion
    Replies: 3
    Last Post: 12 Nov 2009, 12:41 PM
  4. Empty item in combobox list not shown correctly
    By pepgrifell in forum Ext GWT: Help & Discussion (1.x)
    Replies: 0
    Last Post: 27 Mar 2009, 12:36 AM
  5. Programmatic Close Fails if Window is Being Dragged
    By mihaistratus in forum Ext GWT: Bugs (1.x)
    Replies: 2
    Last Post: 18 Jul 2008, 10:26 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •