This example demonstrates reconfiguring a grid dynamically based on the metadata returned by the server
(requires PHP). Click the "Reload Metadata" button to see a new randomized column set and data in the grid.
Note also that the grid is editable on double-click, and that the editors automatically update as well. See below for additional details.
The server response is in this format:
{
data: [{ ... }],
msg: "...",
total: 99,
metaData: {
fields: [{ ... }],
columns: [{ ... }],
idProperty: "id",
messageProperty: "msg",
root: "data"
}
}
The store/model automatically read the fields
config to reconfigure the data model, but you can add any
additional custom data into the metaData
that you need. In this example we've added a columns
config that contains a grid-specific column configuration that can be passed to the grid.reconfigure()
method
in the store's load event handler. You could easily add other widget-specific configurations into the response as well.