Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

ModelAdmin show all results on first load

Go to End

8 Posts   7949 Views


Community Member, 105 Posts

7 January 2010 at 2:13pm

Was wondering if it is possible to show the results of a search (like show everything) when you first click on a ModelAdmin tab instead of having to do a search first?


Forum Moderator, 4102 Posts

7 January 2010 at 2:32pm

Join the club.

It's a huge criticism of ModelAdmin, and personally I can't for the life of me figure out why they built it that way. Somewhere around the forums you'll find a Javascript hack that I use to force a list view by default. If you can't find it let me know and I'll dig it up.


Community Member, 105 Posts

7 January 2010 at 3:22pm

Hey UncleCheese thanks for the response :)

I found the following but still doesn't really provide an answer :

Ingo Mentions

It uses DataObject::$default_sort. You can overload ModelAdmin->getResultsTable() and ModelAdmin->getCustomQuery() for any custom sorting.


You can overload the right template by adding a new Layout template called (see for clues on the necessary markup)

But I guess with out subclassing and overloading most of model admin this would be a real pain.

So if you could dig up that JS hack would be greatly appreciated!


Community Member, 105 Posts

11 January 2010 at 2:30pm

Edited: 13/01/2010 5:03pm

Any luck finding the JS hack UncleCheese?

Edit: Anyone?????


Community Member, 105 Posts

29 January 2010 at 5:44pm

Edited: 02/02/2010 9:02pm

Yes hacky but at least it loads some results when you first go to your ModelAdmin tab anyone has a better way please let me know


class ProductAdmin extends ModelAdmin {


   function init()


(function($) {
$(document).ready(function() {

Note: the above form id passed to the jQuery selector will changed based on what you called your extended ModelAdmin class


Community Member, 98 Posts

21 March 2010 at 11:23am

Edited: 21/03/2010 11:25am

And to trigger an empty search for each tab when clicked add this to CG's function for each managed model:

	$('a[href$=#Form_Product]').click(function() {

Again, replacing Product with your models class name.

The combobox version would just need some tweaking.


Community Member, 9 Posts

12 April 2011 at 9:10am


That worked perfectly.


Community Member, 2 Posts

14 December 2011 at 7:41am

For those of you that are using a Select instead of tabs, you can also try this JQuery solution:

$('#ModelClassSelector select').change(function () {
      $('#SearchForm_holder form[id^=Form_SearchForm]').submit();