Custom Rendering

The ComboBox provides options for customizing the way it renders its elements.

The ComboBox utilizes custom renderers which enable you to moderate the content of its:

Items

To customize the content of each suggestion list item, use the itemRender prop.

The following example demonstrates how to set the itemRender prop of the ComboBox and customize the list elements.

import React from 'react';
import ReactDOM from 'react-dom';

import { ComboBox } from '@progress/kendo-react-dropdowns';
import countries from './countries';

class AppComponent extends React.Component {
    itemRender = (li, itemProps) => {
        const index = itemProps.index;
        const itemChildren = <span style={{ color: "#00F" }}>{li.props.children} {index}</span>;

        return React.cloneElement(li, li.props, itemChildren);
    }

    render() {
        return (
            <div className="example-wrapper">
                <p>Type the name of a European country:</p>
                <ComboBox
                    data={countries}
                    placeholder="e.g. Denmark"
                    itemRender={this.itemRender}
                    style={{ width: "200px" }}
                />
            </div>
        );
    }
}

ReactDOM.render(
    <AppComponent />,
    document.querySelector('my-app')
);

Headers and Footers

To set a header or a footer element in the items popup of the ComboBox, use the header and footer props.

import React from 'react';
import ReactDOM from 'react-dom';

import { ComboBox } from '@progress/kendo-react-dropdowns';
import countries from './countries';

class AppComponent extends React.Component {
    render() {
        return (
            <ComboBox
                data={countries}
                header={<span style={{ marginLeft: '60px' }}>header</span>}
                footer={<span style={{ marginLeft: '60px' }}>footer</span>}
            />
        );
    }
}

ReactDOM.render(
    <AppComponent />,
    document.querySelector('my-app')
);

No Data

To customize the content of the suggestion list when no data is present, use the listNoDataRender prop.

import React from 'react';
import ReactDOM from 'react-dom';

import { ComboBox } from '@progress/kendo-react-dropdowns';

class AppComponent extends React.Component {
    listNoDataRender = (element) => {
        const noData = (
            <h4 style={{ fontSize: '1em' }}>
                <span className="k-icon k-i-warning" style={{ fontSize: '2.5em' }} />
                <br /><br />
                no data here
            </h4>
        );

        return React.cloneElement(element, { ...element.props }, noData);
    }

    render() {
        return (
            <ComboBox
                data={[]}
                listNoDataRender={this.listNoDataRender}
            />
        );
    }
}

ReactDOM.render(
    <AppComponent />,
    document.querySelector('my-app')
);
 /