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 forum.silverstripe.org 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.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

DataObjectManager Without Creating Page


Go to End


9 Posts   4358 Views

Avatar
draft

Community Member, 57 Posts

15 October 2009 at 11:33pm

Hi UncleCheese,

I have the dataobjectmanager working, but my question is, is it possible to use the dataobject manager without creating the page type, so i want to create it like the comments section on the cms.

Thx b4.

Avatar
UncleCheese

Forum Moderator, 4102 Posts

16 October 2009 at 1:02am

Yup. You usually use ModelAdmin for something like that.

Avatar
draft

Community Member, 57 Posts

16 October 2009 at 7:33pm

Thx unclecheese, i got the model admin working, i think it's quite good, just a couple of questions regarding model admin :

1. When i first open the tab, it show nothing on the table field, we need to click the search button to show the data, is it possible to make it show the latest data from the beginning (without press the search button).
2. It doesn't have sort order functionality like dataobjectmanager, is it also possible to make it like dataobject manager?

3. The create data is not using ajax functionality, is there a way to make it working using ajax?

4. Here is a sample of the modeal admin code :
public static $managed_models = array(
'TableName'
);
I notice that the table name will become the title of the tab bar, is it a way we can change the title to whatever i want?

5. On the search functionality, the ID field will become a list box, is it possible to create it as a textbox, so admin can just type it right away without scrolling down to search the right id?

Sorry for this bunch of questions :P

Thx before UncleCheese.

Avatar
UncleCheese

Forum Moderator, 4102 Posts

17 October 2009 at 1:28am

This is too funny. You've literally raised questions and criticisms of ModelAdmin that I've been saying since it came out. It's really kind of eerie. It looks like I wrote your question. Ha.

I just started my first "real" ModelAdmin project yesterday, and I had another user supply me with a set of Javascript-based hacks to change the behavior a bit, like forcing a list view. That's definitely the biggest issue. I have no idea what they were thinking when they designed it that way. Searching on a null set is the most counter-intuitive action to get an all-inclusive list. And the default view containing such useless information "Silverstripe CMS. Please click on the left pane." Ugh. Are you kidding? It's atrociously bad.

I actually asked an SS developer a few weeks ago about this, and told him it was the main thing turning me away from ModelAdmin -- that there was no list view, and he basically laughed and told me, "ModelAdmin is for huge datasets. It's for searching, not listing."

Well, ok. But why not have the last 10 records display by default? Surely anything is better than "Click on the left." amidst a vast empty gray screen.

The other thing you mention about column sorting -- this came up in a discussion with another user yesterday as I was working. The results display in TableListField, which doesn't support column sorting. Fortunately there's a property called $tableClassName (or something to that effect) so you can use a custom object if you like. DOM supports column sorting, so I started thinking about how to get DOM to work with a search result set. It's not impossible, but it looks like a lot of work, so don't expect it anytime soon.

Ugh. Yeah, ModelAdmin is quite disappointing in a lot of ways. If you want those Javascript hacks, let me know.

But otherwise, understand that these are not issues with DataObjectManager, but rather, ModelAdmin, and you need to raise them in another forum. Hopefully with enough noise, Silverstripe will make some fundamental changes.

Avatar
draft

Community Member, 57 Posts

21 October 2009 at 4:57pm

Hi UncleCheese,

Thx for your reply, and glad that i have same opinion with you :P

Hmm well i also thought dataobjectmanager is better than model admin, but the thing is i don't want to create it as a page type, it is so annoying for me to create a report tab but i need to create the page type first on the site tree, but you said dataobjectmanager can't do that right?

So the reason i'm using model admin is just to create a report from a particular table.

And i would love to have your javascript hack for modeladmin unclecheese, anything you think you can make better on model admin i want it :P

Thx before.

Avatar
Israel_Miranda

Community Member, 9 Posts

29 October 2009 at 6:28am

I'd like these javascripts hacks too UncleCheese, if you could attach them to the forum would be very useful.

Avatar
UncleCheese

Forum Moderator, 4102 Posts

29 October 2009 at 6:55am

Here you go:

ModelAdmin_improvements.js

jQuery(document).ready(function() {
               
               var selectChange = function() {
                 var currentModel = jQuery('#ModelClassSelector').children('select');
                 var currentModelName = jQuery('option:selected', currentModel).val();
                 var strFormname = "#Form_SearchForm" + currentModelName;
                 jQuery(strFormname).submit();               
               }
               
               jQuery('#ModelClassSelector').livequery("change",selectChange);
               
               jQuery('#Form_SearchForm_{{YOUR_MODEL_CLASS}}').livequery(function(){
                       jQuery('#Form_SearchForm_Assignment').submit();
               });
               
               selectChange();
});

And I usually add this to the ModelAdmin subclass to get rid of the tabs. That way you get the list view every time you change the model.

	public function SearchClassSelector() 
	{
		return "dropdown";
	}

Avatar
draft

Community Member, 57 Posts

1 November 2009 at 6:15pm

Hey unclecheese,

Thx so much for this hack. I think i have it working, so if i'm not mistaken, the feature is to change the tab to a dropdown, and when we open it, it will query from the first time, then if we change the dropdown we will also get the data right away right?

Is there any other customization you did unclecheese? Like to make the datagrid sortable ?

And also this is i think one of the most important thing, can you tell me how to change the ID to become a textbox instead of dropdown? Because i believe, it will be easier for us to type the ID instead of search it one by one on the drop down list.

Thx before unclecheese.

Go to Top