博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
sencha touch 2 tabpanel中List的不显示问题,解决方案
阅读量:6933 次
发布时间:2019-06-27

本文共 2794 字,大约阅读时间需要 9 分钟。

笔者在做sencha项目的时候碰到一个需求,就是"好友列表"中分为"未确认好友"和"已确认好友",两个都是一个list,自然想到的就是使用tabpanel来实现.

 

但是在sencha touch的开发使用过程中,我们总是会碰到不给高度就不显示的问题,非常之恼火,浪费我大把时间研究

笔者在开发这个需求的时候也碰到了,下来就分享一下方案吧:

 

  1,先来看看有问题的方案,以下是代码:

  

Ext.define("mine.view.ListFriendView", {    extend: "Ext.tab.Panel",    xtype: "listFriendView",    requires: [        'Ext.data.Store'    ],    config: {        tabBarPosition:'top',        style:'background: #ececec;',        cls:'x-tab2',        items: [            {                xtype: "toolbar",                title: "我的好友",                docked: "top",                ui: "dark",                items: {                    xtype: "button",                    cls: "backBtn",                    text: "返回",                    handler: function () {                        var backid = Ext.Viewport.getInnerItems().length                        Ext.Viewport.remove(this.up('listFriendView'), true);                        Ext.Viewport.setActiveItem(backid - 2);                    }                }            },            {          xtype:"list",                title:'未确认好友',           emptyText:"没有数据",                scrollable: true,         itemTpl:"........."            },            {          xtype:"list",                title:'已确认好友',          emptyText:"没有数据",                scrollable: true,         itemTpl:"........."            }        ]    }})

 

这样写的话,如果不给定list的高度,那么这个list是不会被显示出来的.

但是给的高度要是太小,List数据显示不完全,给的太高,如果没有数据的话,emptyText就会被挤到可视区域以外(可以用审查元素看到确实存在,但是在很下面,看不到),这就是困扰到我们的问题,

以下是解决方案,请看代码:

 

Ext.define("mine.view.ListFriendView", {    extend: "Ext.tab.Panel",    xtype: "listFriendView",    requires: [        'Ext.data.Store'    ],    config: {        tabBarPosition:'top',        style:'background: #ececec;',        cls:'x-tab2',        items: [            {                xtype: "toolbar",                title: "我的好友",                docked: "top",                ui: "dark",                items: {                    xtype: "button",                    cls: "backBtn",                    text: "返回",                    handler: function () {                        var backid = Ext.Viewport.getInnerItems().length                        Ext.Viewport.remove(this.up('listFriendView'), true);                        Ext.Viewport.setActiveItem(backid - 2);                    }                }            },            {                title:'未确认好友',                scrollable: true,                xtype:"noMyFriendListView"            },            {                title:'已确认好友',                scrollable: true,                xtype:"myFriendListView"            }        ]    }});

 

这里将两个需要切换的list写到两个单独的view中

"noMyFriendListView","myFriendListView",

然后在这个tabpanel中使用xtype的方式引用这两个view,

这样就完美解决了!

 

 

 

 

 

 

转载于:https://www.cnblogs.com/Brose/p/sencha_tabpanel_list.html

你可能感兴趣的文章
The Multilinear Structure of ReLU Networks
查看>>
前端用到的设计模式之开闭原则. 里氏代换原则
查看>>
第6课 用通配符进行过滤
查看>>
Android Paint类和Color类的介绍
查看>>
清除canvas画布内容--点擦除+线擦除
查看>>
行列转换
查看>>
leetcode 349. Intersection of Two Arrays
查看>>
深研TCP/IP详解卷1开篇
查看>>
apollo实现c#与android消息推送(一)
查看>>
hbase自定义比较器
查看>>
接口与抽象类的区别?区别就是抽象类已经(渐渐地渐渐地)不用了.
查看>>
23种设计模式-享元模式
查看>>
5.29
查看>>
[BZOJ1597]土地购买
查看>>
Python目录常用操作
查看>>
Qt笔记——Event
查看>>
leetcode------Merge Two Sorted Lists
查看>>
leetcode------Binary Tree Preorder Traversal
查看>>
js文档碎片
查看>>
poj2823-Sliding Window
查看>>