I added this to my page:
<script type="text/javascript" src="{!URLFOR($Resource.kendoReact, 'kendoReact/kendo-dropdowns-react-wrapper.min.js')}"></script>
To access a static resource of the kendo react script I downloaded.
Then set this up in page:
class MultiSelectContainer extends React.Component {
constructor(props) {
super(props);
console.log('Setting up multiselect', props.data);
this.dataSource = new kendo.data.DataSource({
data: props.data,
sort: {
field: 'name',
dir: 'asc'
},
group: {
field: 'resourceType',
dir: 'desc'
}
});
this.placeholder = 'Filter By People...';
this.enable = false;
this.minLength = 3;
this.enforceMinLength = false;
this.tagTemplate = '<span class="selected-value" title="#:he.decode(data.name)#" style="color: white;">#:he.decode(data.alias)#</span>';
this.template = $('#dropDownTemplate').html();
this.dataTextField = 'searchName';
this.dataValueField = 'value';
this.filter = 'contains';
this.autoClose = false;
this.onChange = this.onChange.bind(this);
this.onSelect = this.onSelect.bind(this);
}
onSelect = (e) => {
//Erase what the user has typed after they make a selection
e.sender.input.val('');
}
onChange = (e) => {
console.log('MultiSelect Changing', e);
var filteredDataSource = e.sender.dataItems();
//Get selected pills of user filter multi-select, and set their background colors to specified user color (either bland grey, or user defined color)
var selectedTags = $('.k-multiselect li.k-button');
for (var i = 0; i < selectedTags.length; i++) {
if (selectedTags[i].parentNode.id == 'user-filter_taglist') {
//ownerIdArr.push(value[i]);
var tag = $(selectedTags[i]);
var item = $(tag.find('span.selected-value'));
for (var k = 0; k < filteredDataSource.length; k++) {
if (item[0].textContent === he.decode(filteredDataSource[k].alias)) {
tag.css({
'background': filteredDataSource[k].tagColor,
'width': '100px',
'height': '30px',
'font-size': '15px',
'overflow': 'hidden',
'text-overflow': 'ellipsis',
'border-radius': '5px'
});
}
}
}
}
}
render() {
return (
<div>
<MultiSelect
change={this.onChange}
select={this.onSelect}
dataSource={this.dataSource}
placeholder={this.placeholder}
value={this.values} />
</div>
);
}
}
But I get this: ReferenceError: MultiSelect is not defined at MultiSelectContainer.render
.
I am assuming this is how I am bringing in the dropdowns react javascript file. With import, you'd do: import {MultiSelect} from 'blah blah path name';
, so MultiSelect would be defined.
Is it possible to bring in the JS file like I did, and establish what MultiSelect is so it is defined, like in the import method?