This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » support » General discussion » Building Own Generator  (4) 7 Vote(s)
Re: Building Own Generator [message #37630 is a reply to message #37603 ] Wed, 17 October 2007 23:18 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 652
Registered: June 2007
Location: Netherlands
Faithful Member
Because this post seems to be very popular, I would like to ask your help for the problem mentioned in this post: http://www.symfony-project.com/forum/index.php/m/37629/#msg_ 37629

If there is something unclear, please say so.

In short: in the regular theme-generator the method: $this->getColumns(list.display) is used to get a list of columns from the current class. I also want to get a list of columns from other classes/tables as well, but I don't see how I can do this, without rewriting a lot of code. I now use $this->getColumns(sub_class.display), but unfortunately methods like $column->isForeignKey() don't seem to work for this.

Tips/Suggestions or answers are appreciated.

Thanks.


Leon
Re: Building Own Generator [message #37647 is a reply to message #37630 ] Thu, 18 October 2007 03:10 Go to previous messageGo to next message
DrCore  is currently offline DrCore
Messages: 59
Registered: August 2007
Member
I have been struggling with the problem of foreign columns also. Currently I implemented for lists a function which allows you to specify a foreign field like this:
list:
  display: [ field, submodel/field, submodel/submodel/field, submodel/ ]


To make this work, I overloaded the getColumnGetter function of the admin generator. However this does not provide a full solution for filters and edits. My preference would be to add submodel functionality to the sfAdminColumn class and make all theme related files aware on how to deal with foreign classes.

To use submodel fields it is often best to use a peer_method/peer_count_method in the list section for performance.

The documentation in this latest release does not cover the submodel functionality yet. If I'm able to finish my deadline I will write some.

Cheers,
Andre

Re: Building Own Generator [message #37681 is a reply to message #24107 ] Thu, 18 October 2007 12:04 Go to previous messageGo to next message
gouiggou  is currently offline gouiggou
Messages: 44
Registered: October 2005
Location: Paris
Member
Great results, this is an excellent consideration to improve generator!

I discover ExtJS 1.1 thanks to another project and the second version of the ext seems to be very complete release.
I need to develop an internal management application. I've done my choice for symfony (of course...) and ext 2.0.
I would like to give some helpers to use usealy ext features.
I've seen your integration of grids into the generator of symfony, it's look very good.

I can help you lvanderree, but I don't know what youe ar expecting to do concerned your work.
I propose begin the writing of helpers. It would be nice if it could be bundle with what you have done before.

Regards.


Jérôme M.
Re: Building Own Generator [message #37684 is a reply to message #37681 ] Thu, 18 October 2007 12:57 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 652
Registered: June 2007
Location: Netherlands
Faithful Member
Hello and welcome gouiggou.

Any help is appreciated. I uploaded my code to the svn so everyone can collaborate, but maybe some 'guideliness' or initial ideas are in place.

Maybe we together can define the functionality which is desired and create an overview of what is done and what is still needed to be done.

My ideas for now are:

Lists:
  • should be backwards compatible (in the generator.yml file)
  • should be editable (but this can be disabled)
  • filtering should work
  • fields with foreign-keys should show up as an (autocomplete) drop-down combobox

DONE:
  • It is possible to sort on foreign-data fields and combined data-fields (for example full-name (=firstname+lastname)).
  • Data can be send as JSON-data, with respect to credentials
  • (editable)(grouping)grid is generated



PROBLEM:
  • master-detail pages (for example categories, with 0 or more products) are represented in a groupable-grid. Problem is to get a good detail-class instantiation. At the moment foreignkey-fields of detail-classes cannot be detected.


TODO:
  • Extjs does not support multi-column sorting. This functionality can be extended. The symfony code is already prepared for this. Andre to use subclass/field for this)
  • Mixing master-columns and detail-columns. (I like the idea of
  • refreshing the data. You don't want to refresh the entire page to see if there is new data. A refresh button on top of the grid would be nice, which reloads the data from the grid, and all the drop-down-combo-boxes and other extra datastores. Maybe even nicer is to poll or even push these requests from the server. (pushing can be done I think by keeping a data-stream open, which is closed by the server as soon as data is changed for which the client is listening. The client can make a new connection and get all new data as soon as the open data-stream is disconnected).



Edit:
  • should be backwards compatible (in the generator.yml file)
  • forms should be constructed with extjs-methods
  • required fields should show hints when not filled
  • regexps can be added to check input
  • drag-drop can be added, for example for admin_double_lists

DONE:
  • not much



PROBLEM:
  • first have to have editable grids working


TODO:
  • A lot
  • Helpers can be of good use here, so you can use them in edit as well as in lists.


layout.php:
  • an example for a layout.php can be given, which shows how to cache your pages.

DONE:
  • I've got this working. What I do is load every page in a tab-page. I check with the help of the URL if the page is not already loaded, if it is I show that tab-page. I hide the tab-page-headers with CSS so the user does not see a thing.



PROBLEM:
  • Whenever there is a javascript error, no new javascript is executed anymore, so no new pages will be loaded. (The grids are rendered by javascript).


TODO:
  • Maybe make javascript-code more robust, so it can handle errors.


There is a lot more which needs to be done, this are some of my initial ideas.

I will setup a wiki page, so everyone can add his ideas over there.


Leon
Re: Building Own Generator [message #37685 is a reply to message #24107 ] Thu, 18 October 2007 13:12 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 652
Registered: June 2007
Location: Netherlands
Faithful Member
I've added a page to the wiki

http://trac.symfony-project.com/wiki/sfExtjsThemePlugin

If you want to participate and want a trac account, you probably need to contact Fabien?

I will try to update all info over there, and keep you posted on updates over here.


Leon
Re: Building Own Generator [message #37691 is a reply to message #37685 ] Thu, 18 October 2007 14:19 Go to previous messageGo to next message
gouiggou  is currently offline gouiggou
Messages: 44
Registered: October 2005
Location: Paris
Member
Ok good, I already have a trac account.

I will look more in detail extjx code and your generator code.
I will certainly have some questions concerned your ideas.


Jérôme M.
Re: Building Own Generator [message #37692 is a reply to message #37691 ] Thu, 18 October 2007 14:46 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 652
Registered: June 2007
Location: Netherlands
Faithful Member
Nice,

Please tell me what you have found and what you think.

I think together with the community this could eventually get a real nice plugin and useful for a lot of people.

There is still enough which can be done, and if more people are joining in, good documentation and communication seems essential, so I'll try to structure the wiki some more.


Leon
Re: Building Own Generator [message #37822 is a reply to message #37692 ] Sun, 21 October 2007 15:03 Go to previous messageGo to next message
plan-r  is currently offline plan-r
Messages: 42
Registered: October 2007
Location: Cologne (Köln)
Member
Hi Leon,

this plugins looks really great to me.

Where can I get the latest version of it, if I don't have a trac/svn account to check it out from there?

[Updated on: Sun, 21 October 2007 15:07]


Ralf
Re: Building Own Generator [message #37824 is a reply to message #37822 ] Sun, 21 October 2007 15:59 Go to previous messageGo to next message
ja@immune.dk  is currently offline ja@immune.dk
Messages: 3
Registered: October 2007
Location: Denmark
Junior Member
You don't need a svn account to checkout the code. Just check out (or export) the code with your svn client.

svn co http://svn.symfony-project.com/plugins/sfExtjsThemePlugin


svn export http://svn.symfony-project.com/plugins/sfExtjsThemePlugin


You can also see the code through Trac at http://trac.symfony-project.com/browser/plugins/sfExtjsTheme Plugin
Re: Building Own Generator [message #37829 is a reply to message #24107 ] Sun, 21 October 2007 21:52 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 652
Registered: June 2007
Location: Netherlands
Faithful Member
Nice to see that so many people are liking the (intended) functionality of the plugin and joining the symfony forum.

I hope you people can give me some feedback, tips, new ideas and help me/eachother to finish/improve the plugin.

I took this weekend of, I was working a little to hard on everything, but monday I will be back as normal Wink

I hope I can finish the drop-down comboboxes then.


Leon
Re: Building Own Generator [message #37864 is a reply to message #37829 ] Mon, 22 October 2007 14:38 Go to previous messageGo to next message
gouiggou  is currently offline gouiggou
Messages: 44
Registered: October 2005
Location: Paris
Member
I work hard in the plugin.
I'm writing small helper and using them in template and actions of generator.
I'm testing the mixing of master-class and detail-class, I will tell you more soon.


Jérôme M.
Re: Building Own Generator [message #37867 is a reply to message #24107 ] Mon, 22 October 2007 15:05 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 652
Registered: June 2007
Location: Netherlands
Faithful Member
Nice,

I have just committed some small fixes for the drop-down combo-boxes, which are automatically generated for fields which contain foreign-keys, so please do an svn-update.

I'm still looking for ways to get instances of foreign-classes, this should make the code much cleaner and improve some functionality (like finding the foreign-keys of foreign-classes).

François, can't you tell me how this can be/should be done?
(In short again: I have a module for the class 'product-groups', I can of course get a list of 'product-groups' but I also want to get an instance of all items of an other class (for example the product 'products)). This would really help me out.


Leon
Re: Building Own Generator [message #37871 is a reply to message #24107 ] Mon, 22 October 2007 15:58 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 652
Registered: June 2007
Location: Netherlands
Faithful Member
I've put online a small and simple online-demo:

http://fun4me.demon.nl/test/test_dev.php/item

It shows a problem I've posted on the Extjs forum about sorting. (when you change the item-sorting the group-sorting gets changed as well, which is not supposed to happen).

the generator for this (list-class) is:

generator:
  class:              sfPropelAdminGenerator
  param:
    model_class:      Item
    theme:            extjs
    
    list:
      title:            Items in a group
      multisort:        false
      display:          [ groep_id, =name ]
      grouping:
        field:          groep_id
        plugins:        summary
      multisort:        true
      sort:             [ [groep_id, desc], [name, desc] ]
      fields:
        groep_id:
          join_fields:  [ItemPeer::GROEP_ID, GroepPeer::ID]
          sort_column:  GroepPeer::NAME



As you can see, this is not a master-detail (in that case you would have seen empty group-2 as well).
There is something wrong with this stylesheet, but haven't tried to figure out what.

because I have defined groep_id instead of groep, I don't need a Groep->__toString() method. In this case the extjs library does an other call to the server asking for a groep-JSON-data-list, so the translation form id to name can be done client sided (which makes it possible to have drop-down combo-boxes).

Because of this, you are required to have set the theme of the groep in its generator.yml to extjs as well (otherwise there would not be an action called jsonList). For now the json-list of group is required to have a field called 'name', I think I will add an optional option to set a show_field (which can also handle partials).

With the fields: part I tell my plugin on which column to sort, when groep_id is called (sort on group:name instead of its ID).
The sort: part is an array in array, which defines the default sorting, for multiple columns.

(Ps. groep is group in Dutch Wink I could not use group, because symfony does not put a ` around the table-name in the sql query, and group is not a good table name in sql).


Leon
Re: Building Own Generator [message #37890 is a reply to message #24107 ] Mon, 22 October 2007 18:54 Go to previous messageGo to next message
plan-r  is currently offline plan-r
Messages: 42
Registered: October 2007
Location: Cologne (Köln)
Member
hi there,

I am just testing the plugin and I am having a problem I don't understand:

I have created an admin-backend with the plugin from a model with 1 db-table which has 25 fields.
The db-tables content are ca. 7000 records.
I just started with a generator file like that:

generator:
  class:              sfPropelAdminGenerator
  param:
    model_class:      products
    theme:            extjs
    #ajax:             false

    list:
        title:          Produkt-Liste


The result is an empty grid in the module, with all fieldsnames as column headers.

When I add the following to the generator I get a filled grid, and it sorts ascending to the column "id" as it should:

    list:
        title:          Produkt-Liste
        multisort:      true
        sort:           [[id, asc]]
        display:        [id, name]


Then, if I add one or more fields to display in the generator (e.g. db-fields "description", "price" and so on) the result extjs grid is empty again.
When I then click on the column header "id" (in the result grid) to sort it descending, the grid will be filled - but sorted descending, and the grid-paging does not work.

Here is my simple generator:
generator:
  class:              sfPropelAdminGenerator
  param:
    model_class:      products
    theme:            extjs
    #ajax:             false

    list:
        title:          Produkt-Liste
        multisort:      true
        sort:           [[id, asc]]
        display:        [id, name, description, price]



(I always cleared the SF cache between each step)

Is there something I've forgotten while generating the admin-backend and editing the generator?

My symfony-version is 1.0.7

Thanks in advance for a hint...


Ralf
Re: Building Own Generator [message #37896 is a reply to message #37890 ] Mon, 22 October 2007 20:19 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 652
Registered: June 2007
Location: Netherlands
Faithful Member
Do you use firefox, with firebug?

If so, can you check what the result is of the products/jsonList request.

Or else if you don not have firefox+firebug installed, can you browse to http://yourdomain.com/application.php/products/jsonList

And check (or post) the result of this data?

Because I guess that when you only request: [id, name, description, price] and things get broken, there is some data in the jsonData which brakes the json-standards. (like maybe "data..."...data" )

With firebug you can also see if there are problems in the javascript (it is a javascript debugger Surprised )


Leon
Re: Building Own Generator [message #37897 is a reply to message #37890 ] Mon, 22 October 2007 20:30 Go to previous messageGo to next message
plan-r  is currently offline plan-r
Messages: 42
Registered: October 2007
Location: Cologne (Köln)
Member
i've figured out at that my problem described in my previous post results from that:
my db-field "description" which i want to display in the extjs grid is a text-field in the db, and the contents of this field have been saved through a html-textarea with wrap="PHYSICAL", so the field values have been saved to the db with many CR/LF's.

i've overriden the getFieldname() method so that all CR/LF's will be deleted before the json-data for the grid is generated.

that solved the problem described in my pevious post.


Ralf
Re: Building Own Generator [message #37898 is a reply to message #37896 ] Mon, 22 October 2007 20:38 Go to previous messageGo to next message
plan-r  is currently offline plan-r
Messages: 42
Registered: October 2007
Location: Cologne (Köln)
Member
thanx, leon Razz ,
that's exactly what I did meanwhile you wrote your reply to my post Surprised

tonight i'm going to get an edit-interface with your great plugin; may I let you know my experiences here in this thread or should i write you private message?


Ralf
Re: Building Own Generator [message #37899 is a reply to message #37897 ] Mon, 22 October 2007 20:39 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 652
Registered: June 2007
Location: Netherlands
Faithful Member
If the problem is because of your data, maybe a nice solution could be to write a partial field, which transforms the data to a valid output.

But on the otherhand, you should be able to have line-breaks in your data. So I guess that it would be nicer to have this done by the plugin as well.

[Updated on: Mon, 22 October 2007 20:47]


Leon
Re: Building Own Generator [message #37900 is a reply to message #24107 ] Mon, 22 October 2007 20:43 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 652
Registered: June 2007
Location: Netherlands
Faithful Member
Of course you can tell it here,

maybe it encourage other people as well to improve the plugin.

I would definitely would like to know about your experiences and maybe you can already get something to work.


Later on I will also provide my layout-javascript code, so you can see how I make use of tabs to cache my pages on the client. This makes reloading of the pages un-necessary, you only have to refresh the JSON-data.


Leon
Re: Building Own Generator [message #37902 is a reply to message #37867 ] Mon, 22 October 2007 20:55 Go to previous messageGo to next message
plan-r  is currently offline plan-r
Messages: 42
Registered: October 2007
Location: Cologne (Köln)
Member
still working on the list-view...
i am trying to get a multisort, but i don't get it running, here is my generator excerpt:
    list:
        title:          produkte
        multisort:      true
        sort:           [id, name, price]
        display:        [id, name, description, price]

the grid sorts the column "id" asc and desc fine by clikcing the col's header, but it does not sort columns name & price
any hints?
thx in advance Smile


Ralf
Re: Building Own Generator [message #37904 is a reply to message #37902 ] Mon, 22 October 2007 21:17 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 652
Registered: June 2007
Location: Netherlands
Faithful Member
yes I know why this happens.

when you set multisort to true, you can sort on multiple columns at the same time. But there is a BUT and an Ahhh

Lets begin with the Ahhh,
If you sort on [id, name, price], you sort on
id, name AND price.
So it begins with sorting on all ids, then it sorts on all names, and then it sorts on all prices. Because the ids are all different, you cannot notice the sorting on names, nor prices.
And because you mentioned ids first, you also won't notice it when you change sorting of the other fields to descending, only sorting on ids will work.

The multisort functionality is usefull if you have for example product-groups and product-names, or products with the same name, but with a different price. You can then first sort on product-group (or product-name) and then on product-name (or product-price, or all three of them if you like). But you have to leave the ids out!

the array of fields after sort: do not tell you on which fields you are allowed to sort, maybe that is a nice addition one day.

So I hope that this is clear, and you probably want to disable multisort, to have the default behaviour.

Now for the 'BUT'.

Multisorting isn't working with ajax set to true, because at the moment extjs cannot handle sorting on mulitple columns. It can only sort one column at a time. If you disable ajax (ajax: false) you can see how it should work. Someone first has to extend extjs with this functionality before this is possible. I very much like the implementation done with jquery: http://tablesorter.com/docs/ (holding the shift-key while pressing the column headers to sort on multiple columns)
It should be possible to extend extjs with this functionality, but it is not there (yet). At the moment I haven't got time for this yet. And to make it work like the jquery example, there should also be some extention for my plugin, to make the multi-sort reset when you don't hold shift.


You probably want to do add a sort-column to a sort-array when the user holds shift, and when the user does not hold shift, you call an other action which first resets the sort-array, and than adds one column to the empty sort-array.


Leon
Re: Building Own Generator [message #37905 is a reply to message #37904 ] Mon, 22 October 2007 21:45 Go to previous messageGo to next message
plan-r  is currently offline plan-r
Messages: 42
Registered: October 2007
Location: Cologne (Köln)
Member
okay, thanx a lot for the explanation!
so i missunderstood the multisort functionality before.


Ralf
Re: Building Own Generator [message #37906 is a reply to message #37905 ] Mon, 22 October 2007 21:47 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 652
Registered: June 2007
Location: Netherlands
Faithful Member
Maybe I should explain it a little better in the readme.

What did you expect?

defining the columns on which you are allowed to sort?


Leon
Re: Building Own Generator [message #37908 is a reply to message #37906 ] Mon, 22 October 2007 22:14 Go to previous messageGo to next message
plan-r  is currently offline plan-r
Messages: 42
Registered: October 2007
Location: Cologne (Köln)
Member
yep Rolling Eyes


Ralf
icon4.gif  Re: Building Own Generator [message #37915 is a reply to message #37902 ] Tue, 23 October 2007 00:17 Go to previous messageGo to next message
elrems  is currently offline elrems
Messages: 5
Registered: October 2007
Junior Member
Hi,

i try to install your module into the sand box,
but i never see the extjs modules i've only the simple
interface ...

http://www.symfony-project.com/tutorial/1_0/my-first-project

is a there a special configuration to make into symfony to do?

i install into :

C:\symfony\sf_sandbox\plugin\sfExtjsThemePlugin
and copy to
C:\symfony\sf_sandbox\web\sfExtjsThemePlugin

thanks...

Elrems
Re: Building Own Generator [message #37916 is a reply to message #37915 ] Tue, 23 October 2007 00:27 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 652
Registered: June 2007
Location: Netherlands
Faithful Member
You have to change the theme in your generator.yml file, from default to extjs. That should be it.

Have you checked: http://svn.symfony-project.com/plugins/sfExtjsThemePlugin/Ho wTo%20Sandbox.txt
This tutorial tells you "exactly" how you can add the ExtjsThemePlugin to the standard sandbox.

If you use this tutorial and find some errors, or get stuck please tell me, so I can improve it.

Besides there is a readme which you can find here:
http://trac.symfony-project.com/wiki/sfExtjsThemePlugin

if this contains any errors, please say so as well...


Leon
Re: Building Own Generator [message #37924 is a reply to message #37916 ] Tue, 23 October 2007 08:39 Go to previous messageGo to next message
elrems  is currently offline elrems
Messages: 5
Registered: October 2007
Junior Member
Hi,

can you give your "schema.yml" for the "city" project?

and i've a lot of

"Notice: Undefined offset: 1 in C:\symfony_sandbox\cache\frontend\dev\modules\autoAssignment \actions\actions.class.php on line 229"

is that ok?

Elrems

[Updated on: Tue, 23 October 2007 08:51]

Re: Building Own Generator [message #37931 is a reply to message #37924 ] Tue, 23 October 2007 10:07 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 652
Registered: June 2007
Location: Netherlands
Faithful Member
The undefined offsets should not be there. Could you post the code around line 229 (something like 220 to 240, from C:\symfony_sandbox\cache\frontend\dev\modules\autoAssignment \actions\actions.class.php )

my schema.yml file contains the following data:


  // countries
  country:
    countryid: 
      type: INTEGER
      required: true
      autoIncrement: true
      primaryKey: true
    name: 
      type: VARCHAR
      size: 150
      required: true
    abbreviation:          {type: varchar(4), required: false}

  
  // cities
  city:
    cityid:
      type: INTEGER
      required: true
      autoIncrement: true
      primaryKey: true
    countryid:
      type: INTEGER
      required: true
      index: true
      foreignTable: country
      foreignReference: countryid
      onDelete: RESTRICT
      onUpdate: CASCADE
    name:            {type: varchar(150), required: true}



Unfortunately I cannot use the camel-case convention in my project so, no country_id or city_id.

If you have got a list of cities, and use countryid in the display field of your city-list, your country should have a field called name, or otherwise the drop-down combobox cannot be filled. (there will be an option which you can set later on).


Ps. the plugin has no problems with the camel-case convention, and actually I prefer to use it myself as well. When you use camel-case convention the schema.yml would be much simpler:


  // countries
  country:
    id: 
    name:              {type: varchar(150), required: true}
    abbreviation:      {type: varchar(4), required: false}

  
  // cities
  city:
    id:
    country_id:
    name:              {type: varchar(150), required: true}


of course you have to insert some underscores in the generator.yml file in that case.

[Updated on: Tue, 23 October 2007 12:58]


Leon
Re: Building Own Generator [message #38028 is a reply to message #37897 ] Wed, 24 October 2007 12:01 Go to previous messageGo to next message
plan-r  is currently offline plan-r
Messages: 42
Registered: October 2007
Location: Cologne (Köln)
Member
hi again.
i am still doing some tests with my db-tables and the extjs-Theme / grid.

but i guess i have a big name confusion now.
i'll try to explain it.

i have 2 db-tables in the model:
"products" and "folder" (folder means the product category)

table "products" has a FK in field "pid" which refers to the field "id" in the foreign table "folder".

i build the model, and the class files "Products.php", "ProductsPeer.php" and "Folder.php" and "FolderPeer.php" (and the mapping class files) have been created properly.

i then created a backend app and created/initiated the admin-backend-modules.
what i want to do is to show the field NAME (not the id) of the "folder" table as a column in the "products" admin list (therefore i added a _toSTring()-Method to the "Folder.php" which returns the NAME-field of the FOLDER-table instead of the ID).
with the default admin theme that works fine.

after having that wokring i tried to do that with the extjs theme.
i altered the generator.yml as described at the plugins wiki-page:
generator:
  class:              sfPropelAdminGenerator
  param:
    model_class:      Products
    theme:            extjs

    list:
        title:          Produkte
        multisort:      false
#        sort:          [id]
        display:        [folder, name, description, price]
        fields:
             pillefolder:
                join_fields:    [ProductsPeer::ID, FolderPeer::PID]
                sort_column:    FolderPeer::NAME
             name:      {name: Bezeichnung}
             description:      {name: Beschreibung deutsch}


The result is an empty extjs-grid.

Firebug notifies me twice at the firebug-console as follows:
POST :
The requested URL /backend_dev.php/folder/jsonList/filter/query was not found on this server

and the response json-arrays, viewed at Firebug's console, look all the same:
(from: /backend_dev.php/Productex/jsonList?limit=20&start=0)
{totalCount:"98", data:[
{"folder":"<br />
<b>Notice</b>:  Object of class Folder to string conversion in <b>/cache/backend/dev/modules/autoProductex/templates/_json_list_td.php</b> on line <b>6</b><br />
Object","name":"Arriflex 16 ST","description":"Grundausstattung mit: Selbstregelmotor 24/25 B/s, 2 Kassetten 120m, 2 Akkus","price":"80","id":"1"}


The table "products" has the fields "id", "pid", "name" etc.
The table "folder" has also fields with names "id", "name" etc.

Do I have a name confusion with the field names when displaying foreign fields as columns in the grid?
I just want to have a (sortable and later on groupable) column in the extjs-grid "products" which shows the "name" field of the foreign-table "folder".

As I am new to symfony - please be patient with me Rolling Eyes

Thanx a lot in advance!


Ralf
Re: Building Own Generator [message #38031 is a reply to message #38028 ] Wed, 24 October 2007 13:05 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 652
Registered: June 2007
Location: Netherlands
Faithful Member
I will take a look at it later this day, please don't spend (too much) time on it for now, because I think error 1 is due to a 'bug' in my code (I think I hardcoded the slashes, while it should generate ?&=-signs)

Error 2 about the notice does not ring a bell for me right now, but we will figure something out for that as well.


Leon
Re: Building Own Generator [message #38036 is a reply to message #38031 ] Wed, 24 October 2007 14:08 Go to previous messageGo to next message
plan-r  is currently offline plan-r
Messages: 42
Registered: October 2007
Location: Cologne (Köln)
Member
thanx, Leon, for your quick reply.

just one small adjustment to my previous post:
I copied the wrong "join_fields"-line from the generator-code in the post.
in my generator file of course the real line is:
 join_fields:    [ProductsPeer::PID, FolderPeer::ID]

But this is not the solution for the problem.

I'll be online the whole day (.. and night) learning more and more symfony-things, because I think symfony rocks (and your plugin will do as well)! Smile

I wish I were already able to contribute, but I guess this would require a lot more symfony (and extjs) experiences ...


Ralf
Re: Building Own Generator [message #38050 is a reply to message #24107 ] Wed, 24 October 2007 17:04 Go to previous messageGo to next message
gouiggou  is currently offline gouiggou
Messages: 44
Registered: October 2005
Location: Paris
Member
Hi Leon,

For mixing master and detail-class I use the DrCore's solution (overloaded the getColumnGetter for display value) and I modify functions addSortCriteria and addFilterCriteria of action.
Currently I'm playing with the extjs for display the combobox and doing more and more refactoring!

I've extended the sfPropelAdminGenerator to add getColumnGetter and include insinde this new class your getAjaxButtonToToolbarAction.

I've also added a function name getAjaxLinkToAction which add actions defined in object_actions of generator.yml into a RowContextMenu.
This rowContextMenu is building into a new partial called _list_ajax_td_actions and included at the bottom _lit_ajax_layout.

To finish, I add in the columnModel of extjs the possibility to modify boolean with the checkBox editor.

That's all for the moment, I attempt to give you a functionnal version of the plugin and it will be great we discuss about my work.


Jérôme M.
Re: Building Own Generator [message #38052 is a reply to message #38036 ] Wed, 24 October 2007 17:27 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 652
Registered: June 2007
Location: Netherlands
Faithful Member
A fix for Error 1 is commited,

it was a bit more complicated than expected. Not only was the problem that I hardcoded the slashes, it also created more stores for the drop-down boxes than necessary.

When there was no sub_class(.display) defined, it looks at all the columns of your class and for every column which is a foreign-key it would setup a datastore which requested this url which did not exist.

I'll have to look into problem 2, but I found out there are still some other problems left for the datastore. The autocomplete function can brake the entire grid when you reload it, because of the data in the session.

For now you can do a checkout and your problem should be solved.

If you change all occurences of "folder", to its column-name "folder_pid?" AND you table folder has a column "name" AND you set the theme to Extjs in the generator of folder, you will have drop-down boxes instead of plane text-boxes in your grid, when you edit a field...

But probably this will only happen if error2 has been fixed :S


Leon
Re: Building Own Generator [message #38057 is a reply to message #38050 ] Wed, 24 October 2007 18:29 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 652
Registered: June 2007
Location: Netherlands
Faithful Member
Hi Jérôme,

sounds great! I'm looking forward to see your additions and merge them with my work. Espessially the refractoring sounds nice and I would be happy to merge your work with mine (if necessary).


Leon
Re: Building Own Generator [message #38060 is a reply to message #38050 ] Wed, 24 October 2007 20:19 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 652
Registered: June 2007
Location: Netherlands
Faithful Member
I had some time to look at your your second error, and I wonder if you are you sure if your Folder-class has an __toString() method?

see http://www.symfony-project.com/book/1_0/08-Inside-the-Model- Layer#Adding New Methods

[Updated on: Wed, 24 October 2007 20:20]


Leon
Re: Building Own Generator [message #38061 is a reply to message #38060 ] Wed, 24 October 2007 20:27 Go to previous messageGo to next message
plan-r  is currently offline plan-r
Messages: 42
Registered: October 2007
Location: Cologne (Köln)
Member
hi leon,

i was also wondering about the php-notice i've found in the json-array, therefore I triple checked it, but I have the __toString function.
here is my Folder.php:
class Folder extends BaseFolder
{
public function __toString()
{
return $this->getName();
}
}


Ralf
Re: Building Own Generator [message #38064 is a reply to message #38060 ] Wed, 24 October 2007 20:47 Go to previous messageGo to next message
plan-r  is currently offline plan-r
Messages: 42
Registered: October 2007
Location: Cologne (Köln)
Member
P.S.:
I checkout the latest version from svn, seems that it solved error #1, no more 404.
thanx for that!

but i don't understand error 2, because i have a __toString() method in the Folder class.
was my first idea to check that.


Ralf
Re: Building Own Generator [message #38066 is a reply to message #38064 ] Wed, 24 October 2007 21:07 Go to previous messageGo to next message
lvanderree  is currently offline lvanderree
Messages: 652
Registered: June 2007
Location: Netherlands
Faithful Member
I don't understand.

What it says is true, but because you have the __toString() method defined, there should be no problem converting the object to a string.

Can you copy the _json_list_td.php file from your cache to your apps/backend/modules/products/templates folder and change on line 6:


products->getFolder()


to:

products->getFolder()__toString()


or otherwise post this line 6 here


Leon
Re: Building Own Generator [message #38067 is a reply to message #38066 ] Wed, 24 October 2007 21:39 Go to previous messageGo to next message
plan-r  is currently offline plan-r
Messages: 42
Registered: October 2007
Location: Cologne (Köln)
Member
it works!!

i changed the line to:
$products->getFolder()->__toString()

remark: when I don't add the __toString to this line AND still have the __toString in the Folder class - Firebug reports the following in the resulting json-array:

{totalCount:"6908", data:[
{"folder":"<br />
<b>Notice</b>:  Object of class Folder to string conversion in <b>
/htdocs/apps/backend/modules/Productex/templates/_json_list_td.php</b> on line <b>6</b><br /> Object","name":"Abdeckfahne","description":"","price":"2","id":"1737"}


does that help you understanding more?
thanks again, Leon!


Ralf
Re: Building Own Generator [message #38068 is a reply to message #38067 ] Wed, 24 October 2007 22:17 Go to previous messageGo to previous message
lvanderree  is currently offline lvanderree
Messages: 652
Registered: June 2007
Location: Netherlands
Faithful Member
I don't understand it at all...

if you set
ajax:false
in your generator.yml and reload the page in your browser, you would have the 'original' symfony look.

If you then take a look at:
cache/backend/dev/modules/autoProducts/templates/_list_td_ta bular.php

you would see that symfony does the same thing, there should be a line like:
<td><?php echo $products->getFolder() ?></td>


isn't it?


Leon
Previous Topic:i18n form question
Next Topic:German symfony workshops/trainings
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software