Announcement

Collapse
No announcement yet.

Extending a list view, keeping functionality

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Extending a list view, keeping functionality

    I have an entity I've initially created from the Entity Manager and I'm now adding functionality to it in the custom folders.

    I have routing and a controller working, and I can browse to the routes and have it call my functions in the controller, as well as use simple views. That part is fine.


    I want to add some functionality to the Entity's list view, specifically add some more options to the mass actions dropdown, but it will mostly be the same as the default views/record/list so I'm trying to extend it so it can use the default list view functionality for everything else without me needing to write it all again,

    I've got it using my extended view - I can put a breakpoint in the setup function and see it using my code. However, after that it's not loading the list of records, I just get 'No Data' displayed, where it's clearly not loading the objects for the list. I'd have thought that if I didn't override the default functionality it would just use that? I'm calling the prototype's setup function inside my own setup function. Is there something else I need to add to get it to use the default functionality in view/record/list?

    This is my view:

    Code:
    Espo.define('custom:views/mailing-list/list', 'views/record/list', function (Dep) {
    
      return Dep.extend({
    
        setup: function () {
          console.log("In new setup function");
          Dep.prototype.setup.call(this);
        },
    
        massActionList: ['remove', 'merge', 'massUpdate', 'export','addToMailingList'],
    
        massActionAddToMailingList: function () {
    
          // do some stuff, not important for this example
    
        },
    
      });
    });



  • #2
    Nothing else is required to extend the functionality of an Espo front-end "class", the script above looks fine.

    The collection is actually retrieved by the controller not the list view, so I think that the problem could be in the custom controller.

    Check this post which lists the classes and functions involved in generating a list display, hopefully it can help you track where the error might be.
    The idea of this thread is to create a "road map/guide" to help developers find where GUI sections or elements are defined within Espo code so customization projects can be implemented without having to spend a lot of time "finding your way around" the code (like many of us have done) whenever possible.

    Comment


    • #3
      My controller just extends controllers/record, with an extra function I've added to test things are working.:

      Code:
      define('custom:controllers/mailing-list', ['controllers/record'], function (Dep) {
      
        return Dep.extend({
      
          actionHello: function (options) {
            alert('hello world');
            console.log('action: hello');
            console.log(options);
          },
        });
      });
      I've specified the view to use for the list inside Custom/Espo/Custom/Resources/metadata/clientDefs/MailingList.json

      Code:
      {
        "controller": "custom:controllers/mailing-list",
        "views": {
          "list": "custom:views/mailing-list/list",
          "detail": "views/record/detail",
          "edit": "views/record/edit"
        }   
      }
      Isn't that right? I'd have thought that specifying it in MailingList.json would have made it call the default list function in the base controller

      Comment


      • #4
        I'm very busy working on our implementation, but check this post that gives you an example of how to specify custom views. https://forum.espocrm.com/forum/deve...hing#post61108

        Comment


        • #5
          Thanks, that was a lot of help!

          Comment


          • telecastg
            telecastg commented
            Editing a comment
            You're very welcome
        Working...
        X