Autocomplete
Component
<script setup lang="ts">
import { type Column, Filters, Formatters, SlickgridVue, type VanillaCalendarOption } from 'slickgrid-vue';
import { onBeforeMount, type Ref } from 'vue';
const gridOptions = ref<GridOption>();
const columnDefinitions: Ref<Column[]> = ref([]);
const dataset = ref<any[]>([]);
onBeforeMount(() => {
defineGrid();
});
function defineGrid() {
columnDefinitions.value = [
{
id: 'countryOfOrigin', name: 'Country of Origin', field: 'countryOfOrigin',
formatter: Formatters.complexObject,
dataKey: 'code', // our list of objects has the structure { code: 'CA', name: 'Canada' }, since we want to use the code`, we will set the dataKey to "code"
labelKey: 'name', // while the displayed value is "name"
type: 'object',
sorter: Sorters.objectString, // since we have set dataKey to "code" our output type will be a string, and so we can use this objectString, this sorter always requires the dataKey
filterable: true,
sortable: true,
minWidth: 100,
editor: {
model: Editors.autoComplete,
customStructure: { label: 'name', value: 'code' },
collectionAsync: fetch('assets/data/countries.json'), // this demo will load the JSON file asynchronously
onInstantiated: (instance) => console.log('instance', instance), // get instance from 3rd party lib
},
filter: {
model: Filters.autoComplete,
customStructure: { label: 'name', value: 'code' },
collectionAsync: fetch('assets/data/countries.json'),
onInstantiated: (instance) => console.log('instance', instance), // get instance from 3rd party lib
}
}
];
gridOptions.value = {/*...*/};
dataset.value = getData();
}
</script>Component

Last updated