Announcement

Collapse
No announcement yet.

Cannot set list layout

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

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

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

    BWT collection.fetch() is async. Better add await.

    Comment


  • #3
    > but table headers are incorrect

    What exactly is incorrect?

    Comment


    • #4
      Originally posted by yuri View Post
      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 View Post
      What exactly is incorrect?
      <th> is like matching parent (view) entity fields so table become broken

      Comment


      • #5
        Maybe attach a screenshot. Maybe I could recall the problem when I see it.

        Comment


        • #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...
          X