Reputation: 3722
I try to customize multiple select (with selectize.js plugin)
I have the payload with next structure:
[
{id: 1, name: 'First', email: '[email protected]'},
{id: 2, name: 'Second', email: '[email protected]'},
.....
]
how I can customize option to see text in next format
First <[email protected]>
Second <[email protected]>
but when person is selected in input field it should be displayed like
First Second
without additional parameters
Maybe someone can provide link to documentation or solution, because I couldn't find any information about this case.
Thx.
Upvotes: 0
Views: 1279
Reputation: 5566
Selectize has a render
callback function for Custom rendering.
You can take a look here
You can mention it in its config object. I have used it something like below -
config = {
valueField: 'id',
labelField: 'firstName',
searchField: ['id', 'firstName', 'lastName', 'userName', 'cell'],
maxItems: 1,
render: {
item: (item: any, escape: any) => {
return `<div>` +
escape(item.firstName) + ` ` + escape(item.lastName) +
` <span><` + escape(item.userName) + `></span>` +
`</div>`;
},
option: (item: any, escape: any) => {
return this.templateCustomer(item, escape);
}
},
};
Upvotes: 1