Cannot set list layout

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sequencer
    Junior Member
    • Apr 2024
    • 16

    Cannot set list layout

    Without listLayout list renders but table headers are incorrect
    Code:
                const collection = await this.getCollectionFactory().create('MyEntity');
                // const collection = new Collection();
                collection.url = `MyEntity/${this.model.id}/sub_entity`;
                collection.offset = 0;
                collection.maxSize = 20;
                collection.data.select = ['status', 'description'].join(',');
                collection.orderBy = 'createdAt';
                collection.order = 'desc';
                collection.fetch();
                await this.createView('list', 'views/record/list', {
                    selector: '.list-container',
                    collection,
                    rowActionsDisabled: true,
                    buttonsDisabled: true,
                    listLayout: [{ name: 'description' }]
                });​
    Error in browser: Could not set element '#main > .record .list-container'. bullbone.js:1232:32
    Last edited by sequencer; 04-05-2024, 08:41 PM.
  • yuri
    Member
    • Mar 2014
    • 8440

    #2
    Do you have a div with the 'list-container' class in the parent template?

    BWT collection.fetch() is async. Better add await.
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment

  • yuri
    Member
    • Mar 2014
    • 8440

    #3
    > but table headers are incorrect

    What exactly is incorrect?
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment

    • sequencer
      Junior Member
      • Apr 2024
      • 16

      #4
      Originally posted by yuri
      Do you have a div with the 'list-container' class in the parent template?
      Yes, as I mentioned it renders just without specifying layout. Also work same with id selector.
      Adding await to fetch omitting error but table wont render even without listLayout

      Originally posted by yuri
      What exactly is incorrect?
      <th> is like matching parent (view) entity fields so table become broken

      Comment

      • yuri
        Member
        • Mar 2014
        • 8440

        #5
        Maybe attach a screenshot. Maybe I could recall the problem when I see it.
        If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

        Comment

        • sequencer
          Junior Member
          • Apr 2024
          • 16

          #6
          I fixed it. There were several mistakes. I guess main problem was to make sure collection factory entity type matches sub-entity
          - const collection = await this.getCollectionFactory().create('MyEntity'); collection.url = `MyEntity/${this.model.id}/sub_entity`;​
          + const collection = await this.getCollectionFactory().create('SubEntity'); collection.url = `MyEntity/${this.model.id}/sub_entity`;​

          Comment

          Working...