Vue UI Components Documentation
create-vue plus jqwidgets-scripts replaces the old create-jqwidgets-vue-app package, which was built on Vue CLI and Vue 2. Vue CLI is in maintenance mode, and create-vue is the tool the Vue team recommends.
This page sets up a ready-to-edit project with Vite, Vue 3.5, TypeScript, the jQWidgets styles and a working Grid, the same starting point the old package produced.
npm create vue@latest my-app
cd my-app
npm install
npm install jqwidgets-scripts
npm run dev
Then open http://localhost:5173. To see a Grid, replace the two files described below.
npm create vue@latest asks which features to include. For this starter, answer Yes to TypeScript. Vue Router, Pinia, Vitest, Playwright and ESLint are optional; add them if your app needs them.
The command creates a folder called my-app:
my-app/
├── node_modules/
├── public/ # files served as-is, such as the favicon
├── src/
│ ├── assets/ # CSS and images imported from code
│ ├── components/ # example components you can delete
│ ├── App.vue # the root component
│ └── main.ts # creates the app and loads global styles
├── env.d.ts # types for Vite features such as import.meta.env
├── index.html # the page Vite serves; it loads src/main.ts
├── package.json
├── tsconfig.json # references tsconfig.app.json and tsconfig.node.json
├── tsconfig.app.json # compiler options for the code in src/
├── tsconfig.node.json # compiler options for vite.config.ts
└── vite.config.ts
The exact files depend on the features you pick and can change a little between create-vue versions.
Two additions to vite.config.ts make jqwidgets-scripts versions before 27.1.0 work with Vite, and do no harm in 27.1.0. Without them, npm run dev stops with Cannot set properties of undefined (setting 'Globalize') as soon as a Grid, Calendar, DateTimeInput, Form or Scheduler is on the page, and npm run build fails with Unexpected token Semicolon. With 27.1.0 the dev server works without the plugin, and the build fails only with the light-ie and dark-ie themes. Keep the rest of the file create-vue wrote; the additions are the plugin and the css setting:
import { fileURLToPath, URL } from 'node:url'
import { defineConfig, type Plugin } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'
// Before jqwidgets-scripts 27.1.0: globalize.js, which the Grid, Calendar, DateTimeInput, Form and
// Scheduler components load, hands its code `this` as the window. The dev server serves it as
// an ES module, where `this` is undefined; this passes the window instead.
const jqwidgetsGlobalize: Plugin = {
name: 'jqwidgets-globalize-window',
transform(code, id) {
if (id.includes('jqwidgets-scripts/jqwidgets/globalization/globalize.js')) {
return code.replace(/\}\(this\)\);/, '}(window));')
}
},
}
// https://vite.dev/config/
export default defineConfig({
plugins: [
vue(),
vueDevTools(),
jqwidgetsGlobalize,
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
},
},
// Some jQWidgets themes still contain Internet Explorer CSS hacks (*zoom: 1; in 27.1.0 only
// light-ie and dark-ie), which Vite's
// CSS minifier rejects: errorRecovery drops those lines instead of stopping the build.
css: { lightningcss: { errorRecovery: true } },
})
The plugin changes one line of globalize.js, the culture library those five components load: before 27.1.0 it was written for a classic script, where this is the window, and the dev server serves it as an ES module, where this is undefined. The production build is not affected. In 27.1.0 the file finds the window itself, and the plugin changes nothing. errorRecovery lets Vite's CSS minifier drop the Internet Explorer hacks (*zoom: 1) that some themes still contain (in 27.1.0 light-ie and dark-ie), instead of stopping the build.
Replace src/main.ts. Every component needs jqx.base.css; the second import is the theme:
import { createApp } from 'vue';
import 'jqwidgets-scripts/jqwidgets/styles/jqx.base.css';
import 'jqwidgets-scripts/jqwidgets/styles/jqx.tailwind-blue-dark.css';
import App from './App.vue';
createApp(App).mount('#app');
The Vue components are plain JavaScript files, so TypeScript's strict mode rejects importing them (TS7016: Could not find a declaration file). Declare them once in a new file, src/jqwidgets-vue3.d.ts:
// src/jqwidgets-vue3.d.ts
declare module 'jqwidgets-scripts/jqwidgets-vue3/*.vue' {
import type { DefineComponent } from 'vue';
const component: DefineComponent<Record<string, any>, Record<string, any>, any>;
export default component;
}
Other themes are in the same folder, for example jqx.fluent.css, jqx.material.css, jqx.light.css and jqx.dark.css. Pass the theme name to each component's theme prop.
Replace src/App.vue:
<script setup lang="ts">
import JqxGrid from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxgrid.vue';
// Defined globally by the jQWidgets core, which the Grid component imports.
declare const jqx: any;
const products = [
{ name: 'Chai', category: 'Beverages', price: 18, stock: 39 },
{ name: 'Chang', category: 'Beverages', price: 19, stock: 17 },
{ name: 'Aniseed Syrup', category: 'Condiments', price: 10, stock: 13 },
{ name: 'Chef Anton\'s Cajun Seasoning', category: 'Condiments', price: 22, stock: 53 },
{ name: 'Grandma\'s Boysenberry Spread', category: 'Condiments', price: 25, stock: 120 },
{ name: 'Uncle Bob\'s Organic Dried Pears', category: 'Produce', price: 30, stock: 15 },
{ name: 'Northwoods Cranberry Sauce', category: 'Condiments', price: 40, stock: 6 },
{ name: 'Mishi Kobe Niku', category: 'Meat/Poultry', price: 97, stock: 29 },
{ name: 'Ikura', category: 'Seafood', price: 31, stock: 31 },
{ name: 'Queso Cabrales', category: 'Dairy Products', price: 21, stock: 22 }
];
const dataAdapter = new jqx.dataAdapter({
datatype: 'array',
localdata: products,
datafields: [
{ name: 'name', type: 'string' },
{ name: 'category', type: 'string' },
{ name: 'price', type: 'number' },
{ name: 'stock', type: 'number' }
]
});
const columns = [
{ text: 'Product', datafield: 'name', width: 280 },
{ text: 'Category', datafield: 'category', width: 160 },
{ text: 'Price', datafield: 'price', width: 100, cellsformat: 'c2', cellsalign: 'right' },
{ text: 'In stock', datafield: 'stock', cellsalign: 'right' }
];
</script>
<template>
<main>
<h1>Products</h1>
<JqxGrid
theme="tailwind-blue-dark"
:width="700"
:autoheight="true"
:source="dataAdapter"
:columns="columns"
:sortable="true"
:filterable="true"
:pageable="true"
:pagesize="5"
/>
</main>
</template>
You can delete src/components and src/assets now; the new files no longer use them.
| Command | What it does |
|---|---|
npm run dev | Starts the development server on http://localhost:5173. The page updates as you save files. |
npm run build | Type-checks the project with vue-tsc, then writes an optimized production build to dist/. |
npm run preview | Serves the dist/ folder locally so you can test the production build. |
v-model.Browse every Vue component with source code at jqwidgets.com/vue.