Smartview hasmany not returning all the records

:warning:This is a template you must use to report issues. :warning:
You can also drag images, videos and include Preformatted text.

Feature(s) impacted

Fetching has many is not returning all the records we have tried the hasmany example code in the documentation

{{#each @records as |record|}}
  {{#each @record.forest-comments as |comment|}}
    <p>{{comment.forest-text}}</p>
  {{/each}}
{{/each}}

Observed behavior

We are only getting back a limited amount of records attached is a screenshot from the inspector

Expected behavior

We are expecting that when we run the example code to fetch hasmany in the documentation it would return back all the related data

Failure Logs

In this optional section, please:

  • include any relevant log snippets if necessary,
  • or remove this section if left empty.

Context

Please provide in this mandatory section, the relevant information about your configuration:

  • Project name: …
  • Team name: …
  • Environment name: …
  • Agent type & version: …
  • Recent changes made on your end if any: …

Hey @Zero :wave:

This is due to pagination. All your records are paginated for performances reasons, so I’m guessing that your submissionItems are configured to only display 10 records per page, is that right ?

Hi I have it set for 65 records per page, and if I view this table from the a collection that it’s related too in the summary view it also shows 65 records per page. Only when I use the smart view does it limit the records.

I would have thought that using this code

{{#each @records as |record|}}
  {{#each @record.forest-comments as |comment|}}
    <p>{{comment.forest-text}}</p>
  {{/each}}
{{/each}}

would fetch the records based on the page size that has been set.

@jeffladiray just seeing if you know any other issue with this, as we were needing to have this smart view built out ASAP

Hi @Zero :wave: Unfortunately you must change the way you retrieve the datas.
I’m gonna try to give you some exemples to help you to reach your goal.
template.hbs

<div class="c-smart-view">
  <div class="c-smart-view__content">
    <span class="c-smart-view_icon fa fa-{{@collection.iconOrDefault}} fa-5x" {{did-update this.onLad @records}}></span>
    <h1>
      {{@collection.pluralizedDisplayName}}
      ({{@recordsCount}})
    </h1>
      {{#if this.isLoaded}}
        {{#each this.datas as |data|}}
          <p>
            {{data.name}}
            {{#each data.rels as |rel|}}
              <p>{{rel.forest-title}}</p>
            {{/each}}
          </p>
          <br>
        {{/each}}
      {{/if}}
  </div>
</div>

component.js

import Component from '@glimmer/component';
import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
import { inject as service } from '@ember/service';
import { triggerSmartAction, deleteRecords, getCollectionId, loadExternalStyle, loadExternalJavascript } from 'client/utils/smart-view-utils';

export default class extends Component {
  @service store;
  
  @tracked datas = [];
  @tracked isLoaded = false;
  
  @action
  async onLad() {
    if (!this.isLoaded) {
      this.datas = await Promise.all(
        this.args.records?.map(async record => {
          const params = {
            filters: JSON.stringify({
              aggregator: 'and',
              conditions: [{
                field: 'language_id',
                operator: 'equal',
                value: record.id,
              }],
            }),
            'page[number]': 1,
            'page[size]': 50 // here is the thing you want
          };
          const rfs = await this.store.query('forest-film', params);
          return {
            name: record['forest-name'],
            rels: rfs,
          };
        }),
      );
      this.isLoaded = true;
    }
  }
}

Let me know if that help :pray:

@Arnaud_Moncel tried this and it works a bit when i have it loading 50 records it returns back with a ling base64 string. And if I check the console logs the loaded records are showing in there.

But if I reduce the records per page down to 15 then it loads the data properly. As I know I have more then 50 records for the page that I’m trying to view.

In order to help you i need more informations like your smart view code please.