【问题标题】:HTML editor inside grid panel in extjsextjs中网格面板内的HTML编辑器
【发布时间】:2014-08-04 16:16:57
【问题描述】:

我想知道我们是否可以在网格面板中拥有一个 HTML 编辑器列。我的要求是有一个“HTML 编辑器”类型的可编辑网格列,以便在编辑单元格内容时允许设置样式。

【问题讨论】:

    标签: extjs extjs4 sencha-architect


    【解决方案1】:

    你可以在编辑器中拥有任何你想要的东西。请务必控制用户发布/创建的内容,否则如果您在这些编辑器单元格中加载任何 HTML,您将面临安全漏洞。

    演示:https://fiddle.sencha.com/#fiddle/8ej

    Ext.create('Ext.data.Store', {
        storeId:'simpsonsStore',
        fields:['name', 'email', 'phone'],
        data:{'items':[
            {"name":"Lisa", "email":"<b>lisa@simpsons.com</b>", "phone":"555-111-1224"},
            {"name":"Bart", "email":"<i>bart@simpsons.com</i>", "phone":"555--222-1234"},
            {"name":"Homer", "email":"home@simpsons.com", "phone":"555-222-1244"},
            {"name":"Marge", "email":"marge@simpsons.com", "phone":"555-222-1254"}
        ]},
        proxy: {
            type: 'memory',
            reader: {
                type: 'json',
                root: 'items'
            }
        }
    });
    
    Ext.create('Ext.grid.Panel', {
        title: 'Simpsons',
        store: Ext.data.StoreManager.lookup('simpsonsStore'),
        columns: [
            {header: 'Name',  dataIndex: 'name', editor: 'textfield'},
            {header: 'Email', dataIndex: 'email', flex:1,
                editor: {
                    xtype: 'textfield',
                    allowBlank: false
                }
            },
            {header: 'Phone', dataIndex: 'phone'}
        ],
        selType: 'cellmodel',
        plugins: [
            Ext.create('Ext.grid.plugin.CellEditing', {
                clicksToEdit: 1
            })
        ],
        height: 200,
        width: 400,
        renderTo: Ext.getBody()
    });
    

    【讨论】:

    • 谢谢。有没有办法可以将列的 xtype 更改为架构师菜单中存在的组件以外的组件。当我尝试将列的 xtype 从“textfield”更改为“htmleditor”时,我在架构师配置的编辑器列表中找不到“htmleditor”选项。
    • 是的,Architect 只会为您提供每种基本类型的基本编辑器。如果需要,您可以创建自己的自定义字段:existdissolve.com/2012/12/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-15
    • 2011-08-06
    • 2023-03-14
    • 2014-02-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多