[eluser]OverZealous[/eluser]
Your code is fine (although, you could place the $itemList and $rows in an associative array and json_encode them all at once).
I won't be adding the total or options like that for now. One reason is that different libraries expect different results. For example, the result set for a Dojo item store (which I use in my code) looks like this:
The second reason is that, as in your example, it is easy to concatenate JSON data.
The third reason is that total or numRows should usually require a separate query. If you are bothering to use a data grid, the assumption is that there are a lot of rows, and you are paging the results (at least, I hope so).
My code for returning my grid results usually looks something like this (pseudo-code):
Code:
// Create $object somewhere
// Configure the query parameters
$object->where(...);
// Clone before querying for total number of rows
$summary = $object->get_clone();
$total = $summary->count(); // total number of items that match the query
// look up the current page requested
// $start and $page_size come from the client
$object->get($start, $page_size);
// Convert to JSON-compatible result
$response = array();
$response['total'] = $total;
$response['result'] = $object->all_to_array(); // Not available until next release
// send JSON
echo(json_encode($response));
Finally, the next release of DMZ includes the previously mentioned associative array extension, so you can get the data in a form that is easy to convert to JSON if you need to enhance it.