Jump to:

5453 Posts in 1674 Topics by 1198 members

Customising the CMS

SilverStripe Forums » Customising the CMS » ModelAdmin - adding html to the results lists

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

Page: 1
Go to End
Author Topic: 447 Views
  • Futureweb
    Avatar
    Community Member
    232 Posts

    ModelAdmin - adding html to the results lists Link to this post

    Hello,

    when using the modeladmin search, you get the list of results in the main area of the page - including an 'x' to delete the item.

    What I want to do is add a few extra columns - a couple of html links, and a tickbox.

    Using jquery, I'll make the links open popup windows, and the tick box will be used to change 'status' of multiple items at once. I think I know how I can do the jquery bit - but I'm really not sure how to get the links into the table...

    Ideas welcome!
    Cheers

  • swaiba
    Avatar
    Forum Moderator
    1769 Posts

    Re: ModelAdmin - adding html to the results lists Link to this post

    I've got code that I have been meaning to make a module of for sometime that does this (including the tick boxes).

    For now you can always use casting to show some information... (see casting on http://doc.silverstripe.org/sapphire/en/topics/datamodel).

  • Futureweb
    Avatar
    Community Member
    232 Posts

    Re: ModelAdmin - adding html to the results lists Link to this post

    Getting There!

    in the end,, after a load of searching, and some pure luck, I've found a completely different option - rendering the table with a custom template.

    class OrderModelAdmin_CollectionController extends ModelAdmin_CollectionController {   
       
       function ResultsForm($searchCriteria){
          $form = parent::ResultsForm($searchCriteria);
          $form->Fields()->dataFieldByName($this->modelClass)->setTemplate("MyTableListField");
          return $form;
       }
    }

    and putting a custom SS template in mysite/template/includes/

    the template is copy of the silverstripe TableListField.ss. this template also includes ''TableListField_Item.ss" however i combined it into one and added my extra columns in, and some extra buttons at the bottom...

    447 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.