Search code examples
extjssencha-touchsencha-touch-2

Disable/hide toolbar in NestedList


my Friday evening was spent on fighting with unexpected problem) It's about how to disable native toolbar in NestedList component (for Sencha touch 2.3.1).

NestedList is created with Toolbar by default. The last one have default configuration:

toolbar: {docked: 'top', xtype: 'titlebar', ui: 'light', inline: true}

According to API docs.sencha.com/touch/2.3.1/#!/api/Ext.dataview.NestedList-cfg-toolbar toolbar configuration look's like

toolbar : Ext.Toolbar/Object/Boolean

so i suppose that Boolean means display (true) or not (false)

Well, let's do some magic practice, here is my example:

var data = {
     text: 'Groceries',
     items: [{
         text: 'Drinks',
         items: [{
             text: 'Water',
             items: [{
                 text: 'Sparkling',
                 leaf: true
             }, {
                 text: 'Still',
                 leaf: true
             }]
         }, {
             text: 'Coffee',
             leaf: true
         },]
     }, ]
 };

 Ext.define('ListItem', {
     extend: 'Ext.data.Model',
     config: {
         fields: [{
             name: 'text',
             type: 'string'
         }]
     }
 });

 var store = Ext.create('Ext.data.TreeStore', {
     model: 'ListItem',
     defaultRootProperty: 'items',
     root: data
 });

 var nestedList = Ext.create('Ext.NestedList', {
     fullscreen: true,
     title: 'Groceries',
     displayField: 'text',
     store: store,
     //toolbar: false
 });

uncommenting // toolbar: false leads to errors, something like

uncaught TypeError: Object # has no method 'insert'

and so on. Look's like Sencha try to execute 'insert' method on unexisting component (because it's disabled, toolbar is set to false)


Solution

  • Google does not bring me anthing usefull so i was able to fix it by myself.

    The problem was hiding in src/dataview/NestedList.js

    Anyway here is a diff http://www.diffnow.com/?report=o43bd of original file and fixed. Lines ~640 and ~870 are affected.

    Your comments are welcome!

    Thanks