Update Listbox doc and demo

pull/1453/head
mertsincan 2021-08-16 13:48:49 +03:00
parent ba75e9c51c
commit 3c1bfd43dc
3 changed files with 46 additions and 18 deletions

View File

@ -147,6 +147,12 @@ const ListboxEvents = [
description: "Filter value" description: "Filter value"
} }
] ]
},
{
name: "virtualScrollerOptions",
type: "object",
default: "null",
description: "Whether to use the virtualScroller feature. The properties of VirtualScroller component can be used like an object in it."
} }
]; ];

View File

@ -32,6 +32,9 @@
</div> </div>
</template> </template>
</Listbox> </Listbox>
<h5>Virtual Scroll (100000 Items)</h5>
<Listbox v-model="selectedItem" :options="items" optionLabel="label" optionValue="value" :virtualScrollerOptions="{ itemSize: 31 }" style="width:15rem" listStyle="height:250px" />
</div> </div>
</div> </div>
@ -48,6 +51,7 @@ export default {
selectedCity: null, selectedCity: null,
selectedCountries: null, selectedCountries: null,
selectedGroupedCity: null, selectedGroupedCity: null,
selectedItem: null,
cities: [ cities: [
{name: 'New York', code: 'NY'}, {name: 'New York', code: 'NY'},
{name: 'Rome', code: 'RM'}, {name: 'Rome', code: 'RM'},
@ -93,7 +97,8 @@ export default {
{label: 'Tokyo', value: 'Tokyo'}, {label: 'Tokyo', value: 'Tokyo'},
{label: 'Yokohama', value: 'Yokohama'} {label: 'Yokohama', value: 'Yokohama'}
] ]
}] }],
items: Array.from({ length: 100000 }, (_, i) => ({ label: `Item #${i}`, value: i }))
} }
}, },
components: { components: {

View File

@ -235,6 +235,12 @@ export default {
<td>string</td> <td>string</td>
<td>No results found</td> <td>No results found</td>
<td>Text to display when there are no options available. Defaults to value from PrimeVue locale configuration.</td> <td>Text to display when there are no options available. Defaults to value from PrimeVue locale configuration.</td>
</tr>
<tr>
<td>virtualScrollerOptions</td>
<td>object</td>
<td>null</td>
<td>Whether to use the virtualScroller feature. The properties of <router-link to="/virtualscroller">VirtualScroller</router-link> component can be used like an object in it.</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -381,6 +387,9 @@ export default {
</div> </div>
</template> </template>
</Listbox> </Listbox>
<h5>Virtual Scroll (100000 Items)</h5>
<Listbox v-model="selectedItem" :options="items" optionLabel="label" optionValue="value" :virtualScrollerOptions="{ itemSize: 31 }" style="width:15rem" listStyle="height:250px" />
</div> </div>
</template> </template>
@ -391,6 +400,7 @@ export default {
selectedCity: null, selectedCity: null,
selectedCountries: null, selectedCountries: null,
selectedGroupedCity: null, selectedGroupedCity: null,
selectedItem: null,
cities: [ cities: [
{name: 'New York', code: 'NY'}, {name: 'New York', code: 'NY'},
{name: 'Rome', code: 'RM'}, {name: 'Rome', code: 'RM'},
@ -436,7 +446,8 @@ export default {
{label: 'Tokyo', value: 'Tokyo'}, {label: 'Tokyo', value: 'Tokyo'},
{label: 'Yokohama', value: 'Yokohama'} {label: 'Yokohama', value: 'Yokohama'}
] ]
}] }],
items: Array.from({ length: 100000 }, (_, i) => ({ label: \`Item #\${i}\`, value: i }))
} }
} }
} }
@ -470,6 +481,9 @@ export default {
</div> </div>
</template> </template>
</Listbox> </Listbox>
<h5>Virtual Scroll (100000 Items)</h5>
<Listbox v-model="selectedItem" :options="items" optionLabel="label" optionValue="value" :virtualScrollerOptions="{ itemSize: 31 }" style="width:15rem" listStyle="height:250px" />
</div> </div>
</template> </template>
@ -481,6 +495,7 @@ export default {
const selectedCity = ref(); const selectedCity = ref();
const selectedCountries = ref(); const selectedCountries = ref();
const selectedGroupedCity = ref(); const selectedGroupedCity = ref();
const selectedItem = ref();
const cities = ref([ const cities = ref([
{name: 'New York', code: 'NY'}, {name: 'New York', code: 'NY'},
{name: 'Rome', code: 'RM'}, {name: 'Rome', code: 'RM'},
@ -530,7 +545,9 @@ export default {
} }
]); ]);
return { selectedCity, selectedCountries, selectedGroupedCity, cities, countries, groupedCities } const items = ref(Array.from({ length: 100000 }, (_, i) => ({ label: \`Item #\${i}\`, value: i })));
return { selectedCity, selectedCountries, selectedGroupedCity, cities, countries, groupedCities, items, selectedItem }
} }
} }
<\\/script> <\\/script>