Extjs 在使用Ext.create() 创建控件时如何传递参数的问题。

ashou706 2014-06-09 02:11:22

Ext.define("FileUploadWindow", {
extend:'Ext.Window',
title:'文件上传',
addText:'add',
items:[
Ext.create('Ext.ux.uploadPanel.UploadPanel',
{
addFileBtnText: this.addText
}
)
]
});


就是将addText 的值赋给items中创建的panel中的属性 addFileBtnText。由于这些值都是在定义window时动态赋值的。所以怎么才能以参数的方式传递进来。
之前用了 this.addText 、this.controlCt.addText,都不行
...全文
1896 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
ashou706 2014-10-27
  • 打赏
  • 举报
回复
先放着,当有空了试试,说的有道理
门牙太大 2014-06-10
  • 打赏
  • 举报
回复
楼上正解。。。。。
Go 旅城通票 2014-06-09
  • 打赏
  • 举报
回复
通过initComponent来初始化items Ext.define("FileUploadWindow", { extend: 'Ext.Window', title: '文件上传', addText: 'add', initComponent: function () { this.items = Ext.create('Ext.ux.uploadPanel.UploadPanel', { addFileBtnText: this.addText }); this.callParent(arguments); } });
修改后的作用: 通过修改后该版本可以灵活地实例化对象,因此可以更加好地整合到EXTJS框架,目前我已经将该控件集成到了我们用的EXTJS框架,该控件的用法和EXT内的控件一样的使用,下面为一点相关代码: getValue: function () { return this.KE.html(this.tid); }, setValue: function (value) { this.value = value; this.KE.html(this.tid, this.value) this.fireEvent('changed', this); }, onDisable: function () { this.KE.toolbar.disable(this.tid, []); this.KE.readonly(this.tid); this.KE.g[this.tid].newTextarea.disabled = true; }, onEnable: function () { this.KE.toolbar.able(this.tid, []); this.KE.readonly(this.tid, false); this.KE.g[this.tid].newTextarea.disabled = false; }, onRender: function (ct) { Ext.form.HtmlEditor.superclass.onRender.call(this, ct); this.tid = new Date().getTime(); this.textarea = Ext.get(document.createElement('textarea')); this.textarea.setWidth(this.width); this.textarea.setHeight(this.height); this.textarea.dom.name = this.tid; this.textarea.dom.id = this.tid; this.textarea.dom.style.visibility = 'hidden'; this.textarea.dom.value = this.value; this.el.dom.appendChild(this.textarea.dom); this.NVKindEditor = new NVKindEditor(); this.KE = this.NVKindEditor.KE; this.KE.init({ scope: this, id: this.textarea.dom.name, afterChange: function (id, scope) { scope.fireEvent('changed', scope); } }); this.KE.create(this.tid); delete ct; }, KindEditor是基于浏览器的所见即所得(WYSWYG)HTML编辑器,主要应用于CMS、论坛、博客等WEB程序里。 但原有的KindEditor控件不完全是面向对象的,通过改进后该控件可以完全面向对象,如下代码: NVKindEditor = new NVKindEditor(); var KE = NVKindEditor.KE; KE.show({ id: 'content1' }); 而上面的KE和KindEditor控件原有的KE是一样的,examples只列出了demo-01和demo-14两个典型的例子,其它的例子也都是一样的。该版是在KindEditor 3.5.4版本上进行修改的,源码在kindeditor-3.5.4-zh_CN.zip里面,详细请参见 http://www.kindsoft.net/
最近由于项目需要,在Ext中用到了kindEditor。 具体总结如下,希望对还在研究中的朋友有所帮助。 首先,需要在kindEditor官网上下载4.0版本的包(注意,版本一定要是4.0)。 具体地址如下:http://code.google.com/p/kindeditor/downloads/list 具体用在ExtJs中的用法如下 1)对应的JSP需要引入 <link rel=”stylesheet” href=”${pageContext.request.contextPath}/common/kingeditor/themes/default/default.css”/> <link rel=”stylesheet” href=”${pageContext.request.contextPath}/common/kingeditor/plugins/code/prettify.css”/> [removed][removed] [removed][removed] [removed][removed] 其中 ${pageContext.request.contextPath}/common/kingeditor为我在项目中放置kindeditor的目录。 (2)对应的JS 1.声明一个全局的变量 var content; 2. 声明一个Ext文本域控件,文本域控件嵌入kindEditor var kindEditor_are = new Ext.form.TextArea({ id: 'infoContent', name: 'infoContent', listeners: { "render": function (f) { content = KindEditor.create('#infoContent', { uploadJson :rootPath + '/common/kingeditor/jsp/upload_json.jsp?id=' + infoOrgFuncId, fileManagerJson :rootPath + '/common/kingeditor/jsp/file_manager_json.jsp', allowFileManager : false, height: 380, width: 775 }); } } }); 3)页面保存的候需要调用: kindEditor_are.setValue(content.html()); 4)页面修改的候调用 在form.load里加入以下代码: var contentValue = document.getElementById('infoContent').value; content.html(contentValue); 另外,kindEditor的上传功能官方给的在实际项目中有点差别。需要修改下.

87,910

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧