sencha touch carousel 扩展 CardList 可绑定data/store
扩展代码:
/*
*扩展carousel
*通过data,tpl,store配置数据
*/
Ext.define('ux.CardList', {
extend: 'Ext.carousel.Carousel',
xtype: 'cardList',
config: {
//单个项配置
itemConfig: {},
//数据展示模版
tpl: null,
//数据源
store: null,
//数据源
data: null
},
//数据源事件
storeEventHooks: {
load: 'onLoad'
},
//填充数据
updateData: function (data) {
var me = this,
store = me.getStore();
if (!store) {
this.setStore(Ext.create('Ext.data.Store', {
data: data,
autoDestroy: true
}));
} else {
store.add(data);
}
},
//创建store
applyStore: function (store) {
var me = this,
bindEvents = Ext.apply({},
me.storeEventHooks, {
scope: me
});
//获取store,绑定事件
if (store) {
store = Ext.data.StoreManager.lookup(store);
store.on(bindEvents);
}
return store;
},
//数据加载成功
onLoad: function (store) {
var me = this,
tpl = me.getTpl(),
config = me.getItemConfig(),
item;
if (tpl) {
//遍历store,动态添加元素
config.tpl = tpl;
store.each(function (record, index, length) {
config.record = record;
//展示数据,绑定点击事件
item = Ext.factory(config, 'Ext.Container');
item.element.on({
scope: me,
tap: 'onItemTap'
});
me.add(item);
});
}
},
//更新store
updateStore: function (newStore, oldStore) {
var me = this,
bindEvents = Ext.apply({},
me.storeEventHooks, {
scope: me
});
//移除绑定事件,销毁
if (oldStore && Ext.isObject(oldStore) && oldStore.isStore) {
oldStore.un(bindEvents);
if (oldStore.getAutoDestroy()) {
oldStore.destroy();
}
}
if (newStore.getCount()) {
this.onLoad(newStore);
}
},
//触发单项点击事件
onItemTap: function () {
var me = this,
item = me.getActiveItem();
me.fireEvent('itemTap', me, me.getActiveIndex(), item, item.getRecord());
}
});
使用示例:
xtype: 'cardList',
title: '动态',
ui: 'card',
store: 'trendTopList',
height: 231,
tpl: '<div class="imgTitle img" style="background-image:url({TopBarImgPath})"><div class="cardTitle">{Title}</div></div>'
控制层监听:
cardList: {
initialize: 'listInit',
//和list一样的监听
itemTap: 'itemtap'
}
效果图:
sencha touch carousel 扩展 CardList 可绑定data/store的更多相关文章
- sencha touch 评分扩展
原版 :https://market.sencha.com/extensions/sencha-touch-2-rating-star-field 效果: 我的改造版(只是类名变了): Ext.def ...
- sencha touch Carousel 自动切换
代码是在网上找的,忘记原出处了 /** * 跑马灯自动切换 */ Ext.define('ux.RotatingCarousel', { extend: 'Ext.carousel.Carousel' ...
- sencha touch 侧边栏扩展(只隐藏不销毁)
基于Ext.ux.MenuButton改造而来,和它不同的是,不会每次都去销毁侧边栏,只是单纯的隐藏,属性配置方面没啥区别,每次点击按钮显示时,会触发showMenu事件/方法 代码如下: /** * ...
- sencha touch tabsidebar 源码扩展
先上图看效果 没错,这是一个sencha touch 项目,而这里的右边推出效果(下文叫做tabsiderbar),使用插件tabsiderbar来扩展的. 插件js下载地址:http://www.m ...
- 第一步 使用sencha touch cmd 4.0 创建项目、打包(加入全局变量、公用类、自定义扩展、资源文件)
参考资料: http://www.cnblogs.com/qqloving/archive/2013/04/25/3043606.html http://www.admin10000.com/docu ...
- sencha touch百度地图扩展
扩展代码如下: Ext.define('ux.BMap', { alternateClassName: 'bMap', extend: 'Ext.Container', xtype: 'bMap', ...
- sencha touch 百度地图扩展(2014-12-17)
上个版本http://www.cnblogs.com/mlzs/p/3666466.html,新增了一些功能,修复了一些bug 扩展代码如下: Ext.define('ux.BMap', { alte ...
- sencha touch 百度地图扩展(2014-6-24)(废弃 仅参考)
扩展代码如下: Ext.define('ux.BMap', { alternateClassName: 'bMap', extend: 'Ext.Container', xtype: 'bMap', ...
- Sencha touch Panel之间的跳转(如不使用TabPanel或者Carousel控件而产生跳转的动画效果)
常规的Sencha touch 应用都是"header content footer"结构,这样的结构无疑将使用TabPanel来实现,而且TabPanel肯定是card布局,这样 ...
随机推荐
- 为什么要用nginx
1.支持更多的连接数来响应并发请求连接. 2.占用内存小. 3.处理请求的流程和机制决定了他的高并发连接数. 处理并发请求优于apache Web服务器之Nginx详解(理论部分)
- df命令/du命令/磁盘分区
4.1 df命令 4.2 du命令 4.3/4.4 磁盘分区 df命令 磁盘管理df 大小单位是KB,挂载点是linux上的目录 df -h 根据磁盘大小适当调整单位;单位有:Byte ,1KB,1M ...
- GridView如何将分页数据全部导出为EXCEL?
GRIDVIEW分页状态下将全部数据导出 protected void Button2_Click(object sender, EventArgs e)//按button2将gridview将数据导 ...
- Android四大组件之——ContentProvider(二)
Content Resolver介绍: 开发者文档中这么定义的: This class provides applications access to the content model. 这个类为应 ...
- springmvc+freemarker生成静态html文件
参考资料: http://mylfd.iteye.com/blog/1896501 http://www.cnblogs.com/xxt19970908/p/5553045.html 个人实践: 1. ...
- window 平台上面解决不能动态php_mysqli.dll
今天在新服务器部署PHP+APACHE环境,启动的时候报错: PHP Startup: Unable to load dynamic library :php_mysqli.dll 解决办法: 把PH ...
- ios开发之 -- stringByAddingPercentEscapesUsingEncoding方法被替换 iOS9.0
最近在项目中,发现之前的一个方法已经不被建议使用了. 该方法名即题目中提到的: stringByAddingPercentEscapesUsingEncoding,这个方法是用来进行转码的,即将汉字转 ...
- 虚拟机中多个Linux系统之间配置免秘钥访问
1.三个节点cdh1,cdh2,cdh3 2.在每个机器上分别生产公钥对 ssh-keygen -t rsa 3.复制公钥 cd .ssh cat id_rsa.pub >> auth ...
- 【代码审计】DouPHP_v1.3代码执行漏洞分析
0x00 环境准备 DouPHP官网:http://www.douco.com/ 程序源码下载:http://down.douco.com/DouPHP_1.3_Release_20171002. ...
- CPU特性漏洞测试(Meltdown and Spectre)
2018年1月4日,国外安全研究人员披露了名为"Meltdown"和"Spectre"两组CPU特性漏洞,该漏洞波及到近20年的Intel, AMD, Qual ...