extJS如何创建多选?

时间:2011-05-02 10:23:59

标签: extjs

那么,如何创建多选?

我在sencha.com上找到了这个教程:

       var msForm = new Ext.form.FormPanel({
    title: 'MultiSelect Test',
    width:700,
    bodyStyle: 'padding:10px;',
    items:[{
        xtype:"multiselect",
        fieldLabel:"Multiselect<br />(Required)",
        name:"multiselect",
        dataFields:["code", "desc"], 
        valueField:"code",
        displayField:"desc",
        width:250,
        height:200,
        allowBlank:false,
        data:[[123,"One Hundred Twenty Three"],
            ["1", "One"], ["2", "Two"], ["3", "Three"], ["4", "Four"], ["5", "Five"],
            ["6", "Six"], ["7", "Seven"], ["8", "Eight"], ["9", "Nine"]],
        tbar:[{
            text:"clear",
            handler:function(){
                msForm.getForm().findField("multiselect").reset();
            }
        }]
    }],       
    buttons: [{
        text: 'Save',
        handler: function(){
            if(msForm.getForm().isValid()){
                Ext.Msg.alert('Submitted Values', 'The following will be sent to the server: <br />'+ 
                    msForm.getForm().getValues(true));
            }
        }
    }]
});

当我粘贴它,并写入msForm,只是白色屏幕,当我删除此代码时,Everythings完美.. wtf?我也想要多选!!

1 个答案:

答案 0 :(得分:1)

添加代码是不够的!您需要添加CSS和JS文件。你需要添加:

  1. MultiSelect.css
  2. MultiSelect.js
  3. 您还必须根据您的要求使用ItemSelector.js。这些文件位于:

    1. http://dev.sencha.com/deploy/ext-3.3.0/examples/ux/css/MultiSelect.css
    2. http://dev.sencha.com/deploy/ext-3.3.0/examples/ux/MultiSelect.js
    3. http://dev.sencha.com/deploy/ext-3.3.0/examples/ux/ItemSelector.js