cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              const { Form, TreeSelect } = antd;

const FormItem = Form.Item;

let App = React.createClass({
    
        
    generateTreeNode(list, {id = 'id', label = 'name', rootLabel = '全部'} = {}){
        
        let array = [];
        
        if (list.length == 0) return array;
        
        let children = list.map(item => ({value: '' + item[id], key: item[id], label: item[label]}));
        
        
        array = [{value: 'all', key: 'all', label: rootLabel, children: [...children]}];
        return array;
    },
    
  render() {
      
    const commonFilter = {
        dropdownStyle: {maxHeight: '350px', overflow: 'auto'},
        style: {minWidth: '210px'},
        searchPlaceholder: '请选择',
        notFoundContent: '找不到数据',
        getPopupContainer(){
            return document.querySelector("form");
        }
    };
        
    const searchFilterProps = {
        multiple: true,
        treeCheckable: true,
        treeDefaultExpandAll: true,
        //treeNodeFilterProp:  null, 取消注释解决问题2
        filterTreeNode(inputValue, treeNode){
            return treeNode.props.title.toLowerCase().indexOf(inputValue.toLowerCase()) > -1
        },
        showCheckedStrategy: TreeSelect.SHOW_PARENT,
        //inputValue:null, 取消注释解决问题1
        ...commonFilter
     };
    
    let {form:{getFieldDecorator}} = this.props;
      
    let channelDecorator = getFieldDecorator('tracker', {initialValue: ['all']});
      
    let channels = [
        {id:'2a',name:'channel_15'},
        {id:'2b',name:'channel_14'},
        {id:'3c',name:'channeL_13'},
        {id:'4d',name:'channel_12'},
        {id:'5e',name:'channel_11'},
        {id:'6f',name:'channeL_10'}
    ];
            
      
    return (
      <div style={{margin: 5}}>
         <Form inline>
             <FormItem label="渠道">
                        
                 {channelDecorator(<TreeSelect {...searchFilterProps} treeData={this.generateTreeNode(channels)}/>
                 )}
             </FormItem>
         </Form>
      </div>
    );
  }
});

App = Form.create()(App);

ReactDOM.render(<App />, document.getElementById('app'));
            
          
!
999px
Loading ..................

Console