View Full Version : Dynamically load grid using direct store

26 Mar 2010, 5:09 AM
I am trying to load a grid panel using metadata with direct store. But data is not loaded.

var note = Ext.data.Record.create([
{ name: 'Summary', type: 'string' },
{ name: 'Description', type: 'string' },
{ name: 'Date', type: 'date' },
{ name: 'Type', type: 'string' },
{ name: 'ReportedBy', type: 'string' },
{ name: 'Year', type: 'string' }

var notestoreLst = new Ext.data.DirectStore({
paramOrder: 'taxonomyId|categoryType|rowId|caseId|start|limit|sort|dir',
directFn: Test.GetNoteDirect,
paramAsHash: false,
totalProperty: 'total',
idProperty: 'NoteId',
root: 'Note',
fields: note

am getting the following result. but the grid is not loading.

"{ \"success\":true,
{\"name\":\"ReportedBy\",\"header\":\"Reported By\",\"width\":50,\"sortable\":true,\"menuDisabled\":true},
\"Note\" : [
\"Type\":\"ResearchCase Notes\",
\"ReportedBy\":\"Banumathi Seshan\"

14 Jun 2010, 4:41 AM
I am experimenting the same problem in my application. I wonder if this is a bug or missing feature.

The same server side's response would be fine within a JsonStore.

Any clue by an ExtJS expert?

18 Jun 2010, 1:30 AM
Difficult to give a direct answer, however if you guys are familiar with Kohana (http://kohanaframework.org/) then you can setup an instance of the Direct Module (http://www.sencha.com/forum/showthread.php?100688-Ext.Direct-for-Kohana-3) for it that I ported over.

I have included a working example of a DirectStore with a DataGrid with the module. Maybe that can help point you in the right direction.


18 Jun 2010, 1:43 AM
In your example, have you tried to use metadata to describe the datasource to your DirectStore?

Metadata are sent at the same time as data in the ajax call (see debug above). As it may be automatically generated on the service side, it allows you to spare some tedious work / maintenance on the client side.

This feature is very convenient with JsonStore. It can be implemented as a first step towards a dynamic datagrid.

18 Jun 2010, 2:58 AM
Why is the 'result' property in the first post a really long string? It should be JSON data!

18 Jun 2010, 3:13 AM
Why is the 'result' property in the first post a really long string? It should be JSON data!
I don't know. But without escaping, it doesn't work either.

2 Jul 2010, 9:07 AM
Had the same Problem starting with ExtDirect.

Your JSON-result looks like it has been json-encoded twice.

On the server side, if you are using any server-side stack, do NOT return a json-encoded string within your functions, but the "raw" data. The data you are returning will later be encoded to json automatically when it gets processed by your server stack implementation.

example in php, correct:

public function read() {
$result = array();
/* fill array ... */
return $result;


public function read() {
$result = array();
/* fill array ... */
return json_encode($result);

20 Jul 2010, 5:54 PM
Same problem and already solved it. Look at the "result" property, it's value is a string not a config object
So in this case, you should use JsonRaw (or JRaw in new version of Json.net) to return result :)