21281 Posts in 5729 Topics by 2600 members
General Questions
SilverStripe Forums » General Questions » Show Relating DataObject as link? (Plus speed up record view in model admin)
General questions about getting started with SilverStripe that don't fit in any of the categories above.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 1153 Views |
-
Show Relating DataObject as link? (Plus speed up record view in model admin)

6 July 2010 at 11:25pm Last edited: 7 October 2010 2:16am
Hi,
I have several relations ($has_one) that are slowing down the speed of browsing the record inside model admin - because the relating table has a lot of rows and it is read ALL rows to create the drop down.
class ExampleObject extends DataObject
{
static $db = array(
'Stuff' => 'Text',
);static $has_one = array(
'RelationToBigTable' => 'BigTable',
);
}So I changed them to be read only text fields (as they are not for changing in the gui anyway!).
class ExampleObject extends DataObject
{
static $db = array(
'Stuff' => 'Text',
);static $has_one = array(
'RelationToBigTable' => 'BigTable',
);function getCMSFields()
{
$fields = parent::getCMSFields();$fields->insertAfter(new ReadonlyField('readonlyfield','RelationToBigTableID',$this->RelationToBigTableID),'Stuff');
$fields->removeByName('RelationToBigTableID');return $fields;
}
}I wonder if there is a way to link them to the other dataobject (also in the same model admin) so that I could turn it into a link and it would jump to editing that record?
Barry
-
Re: Show Relating DataObject as link? (Plus speed up record view in model admin)

7 October 2010 at 2:12am Last edited: 7 October 2010 2:21am
Hi,
On the off chance that this is of use to someone... here is the answer to my own question...
function getCMSFields()
{
...
$fields->insertBefore(
new LiteralField('testlit', "<button onClick=\"jQuery('#ModelAdminPanel').fn('loadForm',
'admin/<adminsection*>/<DataObject*>/<id*>/edit',function() {})\"> <buttonlabel*></button>"),'ExtraID');
...
}* fields need completing
Barry
-
Re: Show Relating DataObject as link? (Plus speed up record view in model admin)

18 May 2011 at 5:28pm
I need this but i where do I need to put it ?? In the Dataobject ?
-
Re: Show Relating DataObject as link? (Plus speed up record view in model admin)

19 May 2011 at 12:30am
I'm interested in how to do this too, do let me know if you work it out.
Cheers
-
Re: Show Relating DataObject as link? (Plus speed up record view in model admin)

19 May 2011 at 1:52am Last edited: 19 May 2011 1:54am
where do I need to put it ?? In the Dataobject ?
yes
also I should point out I now use this rarely as I use this instead now...
$hasOneCTF = new HasOneComplexTableField($this,DATAOBJECTNAME,DATAOBJECTNAME,null,null,'ID='.$this->DATAOBJECTNAMEID);
$hasOneCTF->setPermissions(array('edit','show'));
$hasOneCTF->Markable = false;
$fields->addFieldToTab("Root.DATAOBJECTNAME", $hasOneCTF);and the above link is actually the js called when tapping the edit button on the tab created by teh above code..
| 1153 Views | ||
|
Page:
1
|
Go to Top |


