Jump to:

3373 Posts in 998 Topics by 712 members

Data Model Questions

SilverStripe Forums » Data Model Questions » ModelAdmin and GridField

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

Page: 1
Go to End
Author Topic: 303 Views
  • Parker1090
    Avatar
    Community Member
    38 Posts

    ModelAdmin and GridField Link to this post

    Hi Guys,
    Playing about with the ModelAdmin and GridField on DataObjects. Theres a few things I would like to do with them, but can't see how to do them, so any help would be appreciated.

    To put you in the picture, I have:
    Invoice to Items (M:N). There are additional fields for the link, such as quantity and price. These fields are shown using the 'GridFieldEditableManyManyExtraColumns' extension.

    I'm trying to do the following, without any luck:

    1. On a line for the item view through the Invoice page, remove the 'Edit' button (so an item itself can't be edited through an invoice view) - Done with canEdit(). Although this didn't work the first time!

    2. Also under Invoice, remove the 'Add Item' button to prevent new items being created this way, but allow linking to existing

    3. Calculate a column, for example, there are two fields of quantity and price - can I show a line total?

    4. On the invoice display, can I calculate the total of the invoice using a sum of point 3 for all 'child' items?

    5. (Lastly) When a new item is linked to the invoice, set the value of 'Price' to the current price defined in 'Item'. The reason it's duplicated is because there's the actual price (in Item), and then there's the agreed price for the client (in the link table). Hope that makes sense!

    I'm sorry there's a few points, but I've been trying to work it out over the last few days with no progress! Any questions, please throw them at me, and I'll try and answer them.

    Many Thanks

  • BenWu
    Avatar
    Community Member
    87 Posts

    Re: ModelAdmin and GridField Link to this post

    Probably you have to write your own FormField rather than using GridField.

    I follow the example of the UserForms module to right my own Formfield to display information in the way i want.

    303 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.