Vue UI Components Documentation
This tutorial connects two grids through Vue state: selecting a customer in the first grid shows that customer's orders in the second, with a summary computed by Vue. It is the usual shape of a master-detail screen.

Use a Vite and Vue 3 app set up as in Add a Grid to a Vue 3 app. The section on constant props in Sorting, filtering and paging from Vue explains why both grids here get props that never change.
With selectionmode="singlerow", the grid raises rowselect when a row is selected. Its event.args.row holds the row's data. The @rowselect handler puts it in a shallowRef:
const ordersGrid = ref<GridMethods | null>(null);
// The selected customer, from the master grid's rowselect event.
const customer = shallowRef<Customer | null>(null);
function onRowSelect({ args }: RowSelectEvent) {
customer.value = args.row;
}
A new selection re-renders the component. The master grid's props are all constants, so the master grid is not re-rendered and keeps its selection. If one of them changed, versions before jqwidgets-scripts 27.1.0 would apply all of them again and the grid would bind its data again; 27.1.0 applies only the changed one.
The selected customer's orders are a computed of the customer's id. A computed passes a change on only when its value is a new one, and the id is a string: selecting the same customer again, even as a new object, changes nothing. The detail grid keeps one adapter, and a watcher puts each new list of orders in its localdata and calls updatebounddata, so the detail grid binds again only when another customer is selected:
// The selected customer's orders. A computed passes a change on only when its value is a new
// one: the id is a string, so the orders change only when another customer is selected.
const customerId = computed(() => customer.value?.id);
const customerOrders = computed(() => orders.filter((o) => o.customerId === customerId.value));
// One adapter for the detail grid. When the orders change, they go into its localdata and the
// detail grid binds to them. (The first time, the grid does not exist yet: it is created with
// them, when the v-if below shows it.)
const orderSettings = {
localdata: [] as Order[],
datatype: 'array',
id: 'id',
datafields: [
{ name: 'id', type: 'number' },
{ name: 'date', type: 'date' },
{ name: 'product', type: 'string' },
{ name: 'quantity', type: 'number' },
{ name: 'total', type: 'number' }
]
};
const orderSource = new jqx.dataAdapter(orderSettings);
watch(customerOrders, (rows) => {
orderSettings.localdata = rows;
ordersGrid.value?.updatebounddata();
});
The detail grid is inside a v-if, so the first selection creates it. The watcher runs before Vue updates the page, so the orders are in the adapter by then, and ordersGrid.value is still null. A new adapter through :source works in 27.1.0, but not before it: earlier versions apply the new source before the defaults of the props the template does not set, and the grid stays on Loading... (see Bind the Vue Grid to data).
Here the orders are already in memory. With a server, give the adapter a url instead, change it when the customer changes (for example to `/api/customers/${id}/orders`), and call updatebounddata: the detail grid loads them.
Everything around the grids is ordinary Vue: the heading, the v-if and v-else, and totals computed from the same orders.
const totals = computed(() => ({
count: customerOrders.value.length,
sum: customerOrders.value.reduce((s, o) => s + o.total, 0)
}));
<template>
<main style="padding: 16px">
<h1>Customers</h1>
<!-- The master grid's props are constants: a new selection re-renders this component,
not the master grid, which keeps the row selected. -->
<JqxGrid
width="100%"
:autoheight="true"
theme="material-purple"
:source="customerSource"
:columns="customerColumns"
selectionmode="singlerow"
@rowselect="onRowSelect"
/>
<section v-if="customer">
<h2>Orders of {{ customer.company }}, {{ customer.city }}</h2>
<p>{{ totals.count }} orders, {{ totals.sum.toLocaleString('en-US', { style: 'currency', currency: 'USD' }) }} in total</p>
<JqxGrid ref="ordersGrid" width="100%" :autoheight="true" theme="material-purple" :source="orderSource" :columns="orderColumns" />
</section>
<p v-else>Select a customer to see their orders.</p>
</main>
</template>
<script setup lang="ts">
import { computed, ref, shallowRef, watch } from 'vue';
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;
interface Customer {
id: string;
company: string;
contact: string;
city: string;
country: string;
}
interface Order {
id: number;
customerId: string;
date: Date;
product: string;
quantity: number;
total: number;
}
// A grid event carries its details in event.args.
interface RowSelectEvent {
args: { rowindex: number; row: Customer };
}
// The grid methods this component calls (on the detail grid).
interface GridMethods {
updatebounddata: () => void;
}
const customers: Customer[] = [
{ id: 'ALFKI', company: 'Alfreds Futterkiste', contact: 'Maria Anders', city: 'Berlin', country: 'Germany' },
{ id: 'BONAP', company: 'Bon app', contact: 'Laurence Lebihan', city: 'Marseille', country: 'France' },
{ id: 'ERNSH', company: 'Ernst Handel', contact: 'Roland Mendel', city: 'Graz', country: 'Austria' },
{ id: 'FRANK', company: 'Frankenversand', contact: 'Peter Franken', city: 'München', country: 'Germany' },
{ id: 'QUEDE', company: 'Que Delícia', contact: 'Bernardo Batista', city: 'Rio de Janeiro', country: 'Brazil' },
{ id: 'WILMK', company: 'Wilman Kala', contact: 'Matti Karttunen', city: 'Helsinki', country: 'Finland' }
];
const products = ['Chai', 'Chang', 'Ikura', 'Konbu', 'Tofu', 'Pavlova'];
const orders: Order[] = Array.from({ length: 60 }, (_, i) => {
const quantity = 1 + ((i * 7) % 15);
return {
id: 10248 + i,
customerId: customers[(i * 5) % customers.length].id,
date: new Date(2026, i % 9, 1 + ((i * 3) % 27)),
product: products[(i * 11) % products.length],
quantity,
total: quantity * (4 + ((i * 13) % 30))
};
});
const customerSource = new jqx.dataAdapter({
localdata: customers,
datatype: 'array',
id: 'id',
datafields: [
{ name: 'id', type: 'string' },
{ name: 'company', type: 'string' },
{ name: 'contact', type: 'string' },
{ name: 'city', type: 'string' },
{ name: 'country', type: 'string' }
]
});
const customerColumns = [
{ text: 'Company', datafield: 'company', width: 200 },
{ text: 'Contact', datafield: 'contact', width: 160 },
{ text: 'City', datafield: 'city', width: 130 },
{ text: 'Country', datafield: 'country' }
];
const orderColumns = [
{ text: 'Order', datafield: 'id', width: 80 },
{ text: 'Date', datafield: 'date', cellsformat: 'yyyy-MM-dd', width: 120 },
{ text: 'Product', datafield: 'product', width: 140 },
{ text: 'Quantity', datafield: 'quantity', cellsalign: 'right', align: 'right', width: 90 },
{ text: 'Total', datafield: 'total', cellsformat: 'c2', cellsalign: 'right', align: 'right' }
];
const ordersGrid = ref<GridMethods | null>(null);
// The selected customer, from the master grid's rowselect event.
const customer = shallowRef<Customer | null>(null);
function onRowSelect({ args }: RowSelectEvent) {
customer.value = args.row;
}
// The selected customer's orders. A computed passes a change on only when its value is a new
// one: the id is a string, so the orders change only when another customer is selected.
const customerId = computed(() => customer.value?.id);
const customerOrders = computed(() => orders.filter((o) => o.customerId === customerId.value));
// One adapter for the detail grid. When the orders change, they go into its localdata and the
// detail grid binds to them. (The first time, the grid does not exist yet: it is created with
// them, when the v-if below shows it.)
const orderSettings = {
localdata: [] as Order[],
datatype: 'array',
id: 'id',
datafields: [
{ name: 'id', type: 'number' },
{ name: 'date', type: 'date' },
{ name: 'product', type: 'string' },
{ name: 'quantity', type: 'number' },
{ name: 'total', type: 'number' }
]
};
const orderSource = new jqx.dataAdapter(orderSettings);
watch(customerOrders, (rows) => {
orderSettings.localdata = rows;
ordersGrid.value?.updatebounddata();
});
const totals = computed(() => ({
count: customerOrders.value.length,
sum: customerOrders.value.reduce((s, o) => s + o.total, 0)
}));
</script>
<template>
<main style="padding: 16px">
<h1>Customers</h1>
<!-- The master grid's props are constants: a new selection re-renders this component,
not the master grid, which keeps the row selected. -->
<JqxGrid
width="100%"
:autoheight="true"
theme="material-purple"
:source="customerSource"
:columns="customerColumns"
selectionmode="singlerow"
@rowselect="onRowSelect"
/>
<section v-if="customer">
<h2>Orders of {{ customer.company }}, {{ customer.city }}</h2>
<p>{{ totals.count }} orders, {{ totals.sum.toLocaleString('en-US', { style: 'currency', currency: 'USD' }) }} in total</p>
<JqxGrid ref="ordersGrid" width="100%" :autoheight="true" theme="material-purple" :source="orderSource" :columns="orderColumns" />
</section>
<p v-else>Select a customer to see their orders.</p>
</main>
</template>
Select Ernst Handel: the heading reads Orders of Ernst Handel, Graz, the detail grid lists ten orders and the summary gives their total. Select another customer and the detail follows, while the first grid keeps the row you selected highlighted.