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.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

How to Increase has_many popup box (GreyBox?) size?


Reply

7 Posts   2210 Views

Avatar
swaiba

6 August 2010 at 9:37pm Forum Moderator, 1796 Posts

Hi,

I have a DataObjectParent with a has_many relation to another DataObjectChild. This, as a managed_model in ModelAdmin, creates a table where I can "Add DataObjectChild" and it pops up a window with the form. I think in a 'GreyBox'.

Is there any way to set the default size a bit larger?

Barry

Avatar
mattclegg

17 August 2010 at 11:43pm Community Member, 56 Posts

This is a really simple change, and I dont know why by default the popup is soo tiny?

Open sapphire/thirdparty/greybox/greybox.js
change line 214 tobe;

GB_ONLY_ONE.setFullScreen(true);

Enjoy full sized popups from any ComplexTableManager ie ModelAdmin/Security

Avatar
klikhier

15 October 2010 at 9:16pm Community Member, 150 Posts

Thanks for this info! Is there a way this can be done without hacking the core. Something like set_popup_width() in Dataobject Manager module?

Avatar
swaiba

17 November 2010 at 11:48pm Forum Moderator, 1796 Posts

I've found a nice way to do this... in MyLeftAndMainDecorator (that I use for stuff needed int eh CMS) add some script...

class MyLeftAndMainDecorator extends LeftAndMainDecorator {
function init() {
Requirements::customScript("GB_show = GB_showFullScreen;");
}
}

(needs "Object::add_extension('LeftAndMain', 'MyLeftAndMainDecorator');" in _config.php)

Avatar
Tony C

9 March 2011 at 11:55am Community Member, 9 Posts

That has a SIDE EFFECT of not refreshing the main panel because the javascript has the wrong no. of params and doesn't call the callback_fn.

The decorator is the right way to do it though, but it needs to be ....

class MyLeftAndMainDecorator extends LeftAndMainDecorator {
   function init() {
      
      $custom = <<<JS
       GB_show = function(caption, url, /* optional */ height, width, callback_fn) {
       GB_initOneIfNeeded();
       GB_ONLY_ONE.defaultSize();
       GB_ONLY_ONE.setFullScreen(true);
       GB_ONLY_ONE.setType("page");
       GB_ONLY_ONE.setCallback(callback_fn);
       GB_ONLY_ONE.show(caption, url);
       return false;
      };
JS;
      
      // Requirements::customScript("GB_show = GB_showFullScreen;");
      Requirements::customScript( $custom );
   }
}

Avatar
swaiba

9 March 2011 at 10:11pm Forum Moderator, 1796 Posts

Many thanks Tony for the tip!

Avatar
SheaDawson

18 July 2011 at 8:49pm Community Member, 46 Posts

That is infinitely better. Thanks guys!