23478 Posts in 18941 Topics by 2878 members
|Go to End|
17 August 2011 at 11:51pm Last edited: 18 August 2011 4:28am
I have a DataObject (named Extra) that has very much outgrown it's original purpuse and has tons of entries (where it was supposed to have less than a hundred, but now is many thousands).
There is a enum type field and effective dates (and a couple of other "filters").
Currently it is one entry in the managed_models in ModelAdmin, but I keep getting asked to split it up.
It would be easier to modify the presentation of this within ModelAdmin rather than the code that is filled with DataObject::get_by_id('Extra'), $somedataobject->ExtraID and many other things.
So my question is how can I add two entries into the managed_models for Extra based on the type of Extra? or is there another way someone can think of to split this dataobject up for easier access/editting?
All help appreciated!
20 August 2011 at 2:52am
Answer to my own question...
Create several ModelAdmin's - set and override the collection controller and add this function...
$query = parent::getSearchQuery($searchCriteria);
$query->where = "Type='Cash Voucher'"; //<-- changing for each type of ModelAdmin
Then to handle the increased number of menu items...
20 August 2011 at 6:40am
Nice! Couldn't help thinking about it, and all the extra menuitems seemed like an obstacle to me. But then I never knew about the ajshort dropdown menu To complete things: how do you handle new items getting the correct value for each type? A hidden field I guess?
23 August 2011 at 8:45am
how do you handle new items getting the correct value for each type? A hidden field I guess?
That part is fine - there are only 3/4 "Types" in the enum that need to be split out. So creating an individual ModelAdmin with a hardcoded extra where clause added in getSearchQuery is fine.
|Go to Top|