Extjs怎么获取多选框的值

怎么样才能通过js页面,使得页面能够获得数据库中多选框的值,进而表现位多选状态
(数据库中已有多选框的值)
跪求各路大神指教,最好有代码演示

http://www.cnblogs.com/lihuiyy/archive/2012/08/20/2647144.html

你的页面是动态页还是静态的?
动态的那不是直接读取出来赋值给页面上的js变量,然后初始化checkboxgroup value配置就行了

静态页就需要Ext.Ajax.request来从服务器端获取数据后Ext.getCmp获取然后初始化checkboxgroup调用setValue设置值

注意上面value属性和setValue的参数值格式为{'cbname'1:true/false,'cbname2':true/false......同名checkbox:['value1','value2'..]}

API:http://docs.sencha.com/extjs/4.1.3/#!/api/Ext.form.CheckboxGroup-method-setValue

 setValue( value ) : Ext.form.CheckboxGroupCHAINABLE
Sets the value(s) of all checkboxes in the group. The expected format is an Object of name-value pairs corresponding to the names of the checkboxes in the group. Each pair can have either a single or multiple values:

A single Boolean or String value will be passed to the setValue method of the checkbox with that name. See the rules in Ext.form.field.Checkbox.setValue for accepted values.
An Array of String values will be matched against the inputValue of checkboxes in the group with that name; those checkboxes whose inputValue exists in the array will be checked and others will be unchecked.
If a checkbox's name is not in the mapping at all, it will be unchecked.

An example:

var myCheckboxGroup = new Ext.form.CheckboxGroup({
    columns: 3,
    items: [{
        name: 'cb1',
        boxLabel: 'Single 1'
    }, {
        name: 'cb2',
        boxLabel: 'Single 2'
    }, {
        name: 'cb3',
        boxLabel: 'Single 3'
    }, {
        name: 'cbGroup',
        boxLabel: 'Grouped 1'
        inputValue: 'value1'
    }, {
        name: 'cbGroup',
        boxLabel: 'Grouped 2'
        inputValue: 'value2'
    }, {
        name: 'cbGroup',
        boxLabel: 'Grouped 3'
        inputValue: 'value3'
    }]
});

myCheckboxGroup.setValue({
    cb1: true,
    cb3: false,
    cbGroup: ['value1', 'value3']
});
The above code will cause the checkbox named 'cb1' to be checked, as well as the first and third checkboxes named 'cbGroup'. The other three checkboxes will be unchecked.

Available since: 3.4.0

Parameters
value : Object
The mapping of checkbox names to values.
Returns
Ext.form.CheckboxGroup
this
Fires
change
Overrides: Ext.form.field.Field.setValue