Difficulty showing paging in Syncfusion Grid when using Vue 2 with class components

Trying to implement paging in a Syncfusion Grid within a class component of a Vue 2 project using TypeScript. I have added the GridPlugin using "Vue.use" in main.ts.

My understanding is that I need to:

  1. Import the Page class from ej2-vue-grids
  2. Create a service named grid with the Page class in an array
  3. Set allowPaging="true" and provide pageSettings

The pageSettings seem to be working as expected since leaving it out displays all rows.

Below is the simplified code snippet:

<template>
  <ejs-grid
    :data-source="data"
    :allow-paging="true"
    :page-settings="pageSettings"
  >
  </ejs-grid>
</template>

<script lang="ts">
import { Component, Provide, Vue } from "vue-property-decorator";
import { Page } from "@syncfusion/ej2-vue-grids";

@Component
export default class Organizations extends Vue {
  @Provide("grid") private grid = [Page];

  data = [
    { ID: 1, Name: "Widget 1" },
    { ID: 2, Name: "Widget 2" },
    { ID: 3, Name: "Widget 3" },
    { ID: 4, Name: "Widget 4" },
    { ID: 5, Name: "Widget 5" },
    { ID: 6, Name: "Widget 6" },
    { ID: 7, Name: "Widget 7" },
    { ID: 8, Name: "Widget 8" },
    { ID: 9, Name: "Widget 9" },
    { ID: 10, Name: "Widget 10" },
  ];
  pageSettings = { pageSize: 5 };
}
</script>

Answer №1

I discovered the solution on a Syncfusion forum post.

A helpful tip for incorporating the Page in class components is to utilize the options syntax within the @Component attribute:

@Component({
  provide: {
    grid: [Page]
  }
})
export default class Organizations extends Vue {

Answer №2

To fulfill your requirements, implementing paging on the grid is necessary. We have created a sample demo showcasing how paging can be integrated into the grid.

<template>    
  <div>
<ejs-grid ref="grid" id="grid" :dataSource="data" height="100%" :allowPaging="true"
  :pageSettings="pageSettings" >
………………………………………..
</ejs-grid>
 </div>
</template>

<script>
import Vue from "vue";
import { GridPlugin, Page } from "@syncfusion/ej2-vue-grids";
import { Browser } from "@syncfusion/ej2-base";
import { data } from "./datasource";

Vue.use(GridPlugin);

export default Vue.extend({
data: () => {
return {
  data: data,
  pageSettings: { pageSize: 5 },
};},
  methods: {},
  provide: {
 grid: [Page],
},});
</script>    

Check out the sample here: https://codesandbox.io/s/admiring-pare-erxy2?file=/src/App.vue

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What are the alternative ways to incorporate ES6 modules into a Node program if we do not specify "type" : "module" in the package.json file?

Currently, I am facing an issue with my server (built on NodeJS) and client (developed using Vue and compiled with vue-cli) sharing some common code. The problem arises because Vue does not support the "type": "module" option, making it ...

How come my dynamic source path doesn't function correctly unless I add an empty string at the end of it?

Recently, I encountered an issue while using Vue.js to dynamically create a source attribute using an object's properties. Here is the code snippet where I faced the problem: <img :src='"../assets/" + project.image.name + "." + project.image. ...

Utilizing consistent CSS styles across VueJS components

Currently tackling a VueJS 2 project and facing issues with scoped styling when cleaning up the code. My setup involves 3 components that share similarities, prompting me to utilize mixins for consolidating the code into one file. Each component makes use ...

Issue with displaying Vue data from vuex in the user interface

I'm facing a challenge in displaying plan data on my Vue application. The data is fetched from an API running locally. Although I have successfully added the data to the store/vuex and verified its correctness using vue dev tools, I am unable to visua ...

Error encountered when initializing a variable within the constructor of a TypeScript file in Angular 4

This is the content of my app.component.html file PL Auth Username: Password : Generate OTP Enter OTP : Login This is the code in my app.component.ts file import { Component, OnInit } from '@angular/core' ...

Issue encountered with the props type upon import, Ts(2322)

Seeking assistance with a TypeScript, StyledComponent, and React project using Create React App. Encountering an error during build time that cannot be ignored. // browser and terminal error TypeScript error in ./src/index.tsx(4,1): Type '{ alt: ...

The Angular4 HttpClient is throwing an error stating that the type 'Observable<Observable<Object>>' cannot be assigned to the type 'Observable<boolean>'

Currently, I am utilizing the Angular 4 http client to fetch data from the server, but I am encountering an error that states: Type 'Observable<Observable<Object>>' is not assignable to type 'Observable<boolean>'. ...

Creating an abstract static factory with a protected constructor in Typescript

I've been working on this code snippet: import { IValueObject } from "../../shared/domain/IValueObject"; import { AbstractNanoidGenerator } from "../../shared/infrastructure/AbstractNanoidGenerator"; export class CompanyID extends ...

Is Vue.JS compatible with AJAX requests for http calls?

I am currently attempting to achieve the following in my HTML: var app = new Vue({ el: '#loginContent', data: { main_message: 'Welcome', isAuthenticated: false, loginErrorMessage: '', ...

Using Angular to Apply a Custom Validation Condition on a FormGroup Nested Within Another FormGroup

I am facing an issue with my form validation logic. I have a set of checkboxes that need to be validated only when a specific value is selected from a dropdown. The current validator checks the checkboxes regardless of the dropdown value. Here's the c ...

Should I write out the typescript .d.ts file by hand or generate it automatically

When using Typescript, you can utilize the "declaration": true" option in tsconfig to automatically generate d.ts files from your existing Typescript code. Although they may not be as concise as manually written ones, I am curious if there is any downside ...

Having trouble locating modules or properties with ANTLR4 TypeScript target?

Having reached a frustrating impasse, I am seeking assistance with a perplexing issue. My attempt to integrate TypeScript with ANTLR4 has hit a snag, and despite exhaustive efforts, I am unable to pinpoint the root cause (with limited documentation availab ...

axios encountering a 400 bad request error during the get request

I've hit a roadblock for some time now while trying to make a call to my API to fetch data using the GET method. I keep getting a 400 bad request error in Postman, even though I am able to successfully retrieve the data with a status code of 200. I ha ...

What is the best way to assign default values when destructuring interfaces within interfaces in TypeScript?

My goal here is to create a function that can be used with or without arguments. If arguments are provided, it should work with those values; if not, default values should be used. The issue I'm facing is that although there are no TypeScript errors ...

Seeking a method to display a tooltip exclusively when the element is cut off

Can someone assist me with finding a solution to display the tooltip element only when the span element is truncated? <q-td v-for="(col,index) in props.cols" :key="col.name" :props="props"> <span class="t ...

A guide on incorporating Union Types in TypeScript

Currently utilizing typescript in a particular project where union types are necessary. However, encountering perplexing error messages that I am unsure how to resolve. Take into consideration the type definition below: type body = { [_: string]: | & ...

Error message: Unable to load image from local source in Vue application

I am currently working on creating a simple dice roll game in VueJs. However, I encountered an issue with using the dice images as it keeps giving me a 404 error. When I attempted to use require(), it stated that the function was not defined. After some t ...

Unable to locate the "fcm-node" module in Node.js with TypeScript

When working on a TypeScript project, I usually rely on the fcm-node package to send Firebase push notifications in Node.js. However, this time around, I faced an issue. I know that for TypeScript projects, we also need to install type definitions (@types ...

What is the local date format for the Ionic DatePicker?

I have successfully implemented a DatePicker in my Ionic Project, but the date is displaying in the wrong time format. Here is my function: showDatePicker(){ this.datePicker.show({ date: new Date(), mode: 'date', allowOldDates: fal ...

Is there a way for me to retrieve a collection of objects that have been added to an array in Vue.js?

Kindly review the following codes: sidebar_components: [ { title: "Admin Management", href: "javascript:void(0)", idAcc: "accordion-1", value: ["this is a test 1", "this is test 2&q ...