ListComponent.vue 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <template>
  2. <main>
  3. <ejs-grid :dataSource="data" :allowPaging="true" :pageSettings='pageSettings' :enableHeaderFocus="true">
  4. <e-columns>
  5. <slot></slot>
  6. </e-columns>
  7. </ejs-grid>
  8. </main>
  9. </template>
  10. <script lang="ts">
  11. import {defineComponent, ref, useFetch} from '@nuxtjs/composition-api'
  12. import { Page } from "@syncfusion/ej2-vue-grids";
  13. import {Query,Collection, Model} from "@vuex-orm/core";
  14. export default defineComponent({
  15. props: {
  16. query:{
  17. type: Object as () => Query,
  18. required: true
  19. }
  20. },
  21. setup({query}){
  22. const pageSettings = { pageSize: 30 }
  23. const data = ref([] as Collection<Model>)
  24. const { fetch, fetchState } = useFetch(async () => {
  25. const collection = await query.get();
  26. data.value = collection
  27. })
  28. return{
  29. pageSettings,
  30. data
  31. }
  32. },
  33. provide: {
  34. grid: [Page]
  35. }
  36. })
  37. </script>
  38. <style>
  39. .e-grid .e-gridheader {
  40. position: -webkit-sticky;
  41. position: sticky;
  42. top: 58px; /* The height of top nav menu. */
  43. z-index: 1;
  44. }
  45. </style>