constructor() {
super(...arguments);
// define the JSON of data
this.colorsData = [
{
Color: 'Chocolate',
Code: '#75523C',
Style: 'background:pink;width:100px'
},
{ Color: 'CadetBlue', Code: '#3B8289', Style: 'width:290px' }
];
// maps the appropriate column to fields property
this.fields = { text: 'Color', value: 'Code' };
// set the value to MultiSelect
// bind the tagging event
this.onTagging = e => {
var proxy = e;
e.setClass(e.itemData[this.fields.text].toLowerCase());
setTimeout(e => {
if (
document.querySelector('.e-chips.chocolate') &&
document.querySelector('.e-chips.chocolate').innerText ===
proxy.itemData.Color
)
document.querySelector('.e-chips.chocolate').style =
proxy.itemData.Style;
});
};
}
render() {
return (
<div className="col-lg-12 control-pane">
<div className="control-section ms-chip-customize">
<div id="multi-customize" className="control-styles">
<h4>Chip Customization</h4>
<MultiSelectComponent
id="chip-customization"
dataSource={this.colorsData}
fields={this.fields}
mode="Box"
placeholder="Favorite Colors"
tagging={this.onTagging.bind(this)}
/>
</div>
</div>
</div>
);
}
} |