[]
The dataPath property specifies where the record collection is located within parsed data.
It is typically used together with:
schema.type = "xml"
Nested JSON structures
During fetch(), the data source is first parsed according to schema.type.
Then dataPath is used to locate the array of records that will populate the table.
You must define dataPath when the parsed root value is not an array.
During fetch(), DataManager expects the resolved record collection to be an array. If the root parsed result is an object, you must use dataPath to select the property that contains the array of records.
If dataPath is not specified:
The root parsed result is treated as the record collection.
If the root value is not an array, an error will occur during fetch().
Consider the following XML data:
<root>
<data>
<items>
<row>
<id>1</id>
<name>Alice</name>
</row>
<row>
<id>2</id>
<name>Bob</name>
</row>
</items>
</data>
</root>The actual records are located at:
root.data.items.rowConfiguration:
const table = dataManager.addTable("employees", {
data: `
<root>
<data>
<items>
<row>
<id>1</id>
<name>Alice</name>
</row>
<row>
<id>2</id>
<name>Bob</name>
</row>
</items>
</data>
</root>
`,
schema: {
type: "xml",
dataPath: "root.data.items.row"
}
});After fetch(), the table contains two records.
dataPath can also be used with nested JSON data.
Example:
const table = dataManager.addTable("employees", {
data: {
meta: { version: 1 },
payload: {
items: [
{ id: 1, name: "Alice" },
{ id: 2, name: "Bob" }
]
}
},
schema: {
dataPath: "payload.items"
}
});The table records are extracted from payload.items.
dataPath uses dot notation.
Each segment represents a nested property.
The final resolved value must be an array of records.
If the resolved path does not exist or does not reference a valid collection, an error will occur during fetch().
dataPath:
Selects the record collection from parsed data
Is commonly required for XML
Can be used for nested JSON
Must resolve to an array
It does not define columns or data behavior.
Column structure is configured separately using schema.columns.