Documentation
This tutorial connects two grids: selecting a customer in the first grid shows that customer's orders in the second, with a heading and a summary written by the page. It is the usual shape of a master-detail screen.

Set up a page as in Bind the jQuery Grid to data. Both grids are plain grids with selection, so the page needs only these files:
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27/jqwidgets/jqxcore.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27/jqwidgets/jqxdata.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27/jqwidgets/jqxbuttons.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27/jqwidgets/jqxscrollbar.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27/jqwidgets/jqxgrid.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27/jqwidgets/jqxgrid.selection.js"></script>
With selectionmode: 'singlerow', the grid raises rowselect when a row is selected, with the mouse or with the arrow keys. Its event.args.row holds the row's data and event.args.rowindex its index. Attach the handler with the on method of the grid's element: grid events do not reach addEventListener.
// The grid raises rowselect with the selected row's data in event.args.row.
$('#customers').on('rowselect', (event) => {
showOrders(event.args.row);
});
The master grid is not touched when the detail changes, so it keeps the selected row highlighted.
The detail grid is created once, with an empty array as its data. Its source is a settings object kept in a constant, so the page can change its rows later:
// The detail grid starts empty. Its source keeps the settings, and its rows change with
// the selection.
const orderSource = {
localdata: [],
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' }
]
};
$('#orders').jqxGrid({
theme: 'fluent',
width: '100%',
autoheight: true,
source: new $.jqx.dataAdapter(orderSource),
columns: [
{ 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' }
]
});
When a customer is selected, the page puts that customer's orders in the source's localdata and calls updatebounddata, and the detail grid binds to them:
function showOrders(customer) {
const own = orders.filter((o) => o.customerId === customer.id);
// New rows for the detail grid: put them in its source and bind again.
orderSource.localdata = own;
$('#orders').jqxGrid('updatebounddata');
// textContent: the company name is shown as text, whatever it contains.
document.getElementById('detailTitle').textContent = `Orders of ${customer.company}, ${customer.city}`;
const sum = own.reduce((s, o) => s + o.total, 0);
document.getElementById('detailSummary').textContent =
`${own.length} orders, ${sum.toLocaleString('en-US', { style: 'currency', currency: 'USD' })} in total`;
document.getElementById('hint').hidden = true;
document.getElementById('detail').hidden = false;
}
The detail section is hidden until the first selection. A grid created inside a hidden element lays itself out when the element is shown, so the detail grid can be created with the page.
Here the orders are already in the page. With a server, give the detail source a url instead of localdata, change the URL to the selected customer's orders (for example /api/customers/${customer.id}/orders), and call updatebounddata the same way: the grid loads the new URL.
The heading and the summary are set with textContent, so a company name is shown as text whatever characters it contains. The total is formatted with toLocaleString.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Customers</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27/jqwidgets/styles/jqx.base.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27/jqwidgets/styles/jqx.fluent.css">
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27/jqwidgets/jqxcore.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27/jqwidgets/jqxdata.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27/jqwidgets/jqxbuttons.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27/jqwidgets/jqxscrollbar.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27/jqwidgets/jqxgrid.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27/jqwidgets/jqxgrid.selection.js"></script>
</head>
<body>
<main style="padding: 16px;">
<h1>Customers</h1>
<div id="customers"></div>
<p id="hint">Select a customer to see their orders.</p>
<section id="detail" hidden>
<h2 id="detailTitle"></h2>
<p id="detailSummary"></p>
<div id="orders"></div>
</section>
</main>
<script type="module">
const customers = [
{ 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 = 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))
};
});
$('#customers').jqxGrid({
theme: 'fluent',
width: '100%',
autoheight: true,
selectionmode: 'singlerow',
source: 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' }
]
}),
columns: [
{ text: 'Company', datafield: 'company', width: 200 },
{ text: 'Contact', datafield: 'contact', width: 160 },
{ text: 'City', datafield: 'city', width: 130 },
{ text: 'Country', datafield: 'country' }
]
});
// The detail grid starts empty. Its source keeps the settings, and its rows change with
// the selection.
const orderSource = {
localdata: [],
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' }
]
};
$('#orders').jqxGrid({
theme: 'fluent',
width: '100%',
autoheight: true,
source: new $.jqx.dataAdapter(orderSource),
columns: [
{ 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' }
]
});
function showOrders(customer) {
const own = orders.filter((o) => o.customerId === customer.id);
// New rows for the detail grid: put them in its source and bind again.
orderSource.localdata = own;
$('#orders').jqxGrid('updatebounddata');
// textContent: the company name is shown as text, whatever it contains.
document.getElementById('detailTitle').textContent = `Orders of ${customer.company}, ${customer.city}`;
const sum = own.reduce((s, o) => s + o.total, 0);
document.getElementById('detailSummary').textContent =
`${own.length} orders, ${sum.toLocaleString('en-US', { style: 'currency', currency: 'USD' })} in total`;
document.getElementById('hint').hidden = true;
document.getElementById('detail').hidden = false;
}
// The grid raises rowselect with the selected row's data in event.args.row.
$('#customers').on('rowselect', (event) => {
showOrders(event.args.row);
});
</script>
</body>
</html>
Select Ernst Handel: the heading reads Orders of Ernst Handel, Graz, the detail grid lists ten orders and the summary reads 10 orders, $1,780.00 in total. Press the down arrow: Frankenversand is selected and the detail follows, while the first grid keeps the selected row highlighted.