【问题标题】:Disable/hide toolbar in NestedList在 NestedList 中禁用/隐藏工具栏
【发布时间】:2013-12-20 20:21:52
【问题描述】:

我的星期五晚上花在解决意外问题上)这是关于如何禁用 NestedList 组件中的原生工具栏(对于 Sencha touch 2.3.1)。

NestedList 默认使用 Toolbar 创建。最后一个有默认配置:

工具栏:{停靠:'top',xtype:'titlebar',ui:'light',内联:true}

根据 API docs.sencha.com/touch/2.3.1/#!/api/Ext.dataview.NestedList-cfg-toolbar 工具栏配置看起来像

工具栏:Ext.Toolbar/Object/Boolean

所以我认为布尔值意味着显示(真)或不显示(假)

好吧,让我们做一些magic练习,这是我的例子:

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
 });

取消注释// toolbar: false 会导致错误,例如

uncaught TypeError: Object # has no method 'insert'

等等。看起来像 Sencha 尝试在不存在的组件上执行 'insert' 方法(因为它被禁用,工具栏设置为 false)

【问题讨论】:

    标签: extjs sencha-touch sencha-touch-2


    【解决方案1】:

    也许是一个迟到的答案,但我偶然发现了你的问题,并且我设法在没有对源文件进行任何修改的情况下解决了问题。

    只需在嵌套列表的配置中设置toolbar:{hidden:true}

    config: {
        // other settings
        toolbar: {hidden: true}
    }
    

    让我知道这是否适合您,或者您是否希望我制作小提琴!

    【讨论】:

      【解决方案2】:

      Google 没有给我带来有用的东西,所以我可以自己修复它。

      问题隐藏在src/dataview/NestedList.js

      无论如何,这里是原始文件的差异http://www.diffnow.com/?report=o43bd 并已修复。 ~640 和 ~870 行受到影响。

      欢迎您的 cmets!

      谢谢

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-02-22
        • 2012-03-27
        • 2023-03-26
        • 1970-01-01
        • 2022-01-10
        相关资源
        最近更新 更多