PDA

View Full Version : Ext stores / nested json / model names / multidimensional arrays / flattening / grids



heratech
17 Apr 2012, 1:43 AM
Hi,
I am using Extjs 4.1 rc3 and Ext Direct and Cakephp.
Example list of users: User belongsto Group, HasOne profile
When cakephp returns data it returns it in a format like:


[0] => Array
(
[User] => Array
(
[US_KEY] => 366
[US_NAME] => "John Smith"
)


[Profile] => Array
(
[PR_KEY] => 290
[PR_COUNTRY] => "UK"
[PR_TIMEZONE] => "GMT"
)


[Group] => Array
(
[GR_KEY] => 413
[GR_NAME] => "Administrators"
}
}
[1] => Array
{
[User]...continued


I keep having to flatten these arrays for grids and forms then unflatten them when sending forms/grid filters back (because cakephp needs fields for filtering in the format Model.fieldname - e.g User.US_NAME).

I know extjs has field mappings and the record option in json reader. For the grid filtering i created an override that instead of using the column dataIndex for fieldname it uses a new attribute (postFieldName for example).

I am just wondering what is the best way to handle this.

Thanks

Dumas
25 Jun 2012, 12:14 PM
Hello,

I have wondered the same. After a few projects I really got anoyed of having to configure this and create a lot of cake views all the time. So I started together with some colleges a project which does all of this for you, very much like cake rapid developing.

You might wanna take a loot at the project:
http://banchaproject.org

Best regards,
Roland