Need a special offer?Find out if your project fits.
+

Update members on data source change (custom api)

Answered
Ilaria asked on January 19, 2023

Hi, I found an issue regarding the 'members' call for a customdatasource api (last version: 2.9.42)
I see that there is a similar issue (Custom Data Source - DELETE issue with the API updateData) but honestly I dont't understand if it's the same use-case.
My data source changes depending on user actions so, it might happen that memebers also change.
The fact is, for example: if in the first call I have 4 member for a certain field, and in the second call one of this is removed from the datasource, the filter mask for that field still shows 4 members, even if the 'members' call returns the correct values.
I prepared a sample (very simplified sample of my implementation... sorry for the very ugly hardcoded code) by modifying your sample solution (solution.zip)
On the first loading I have 4 values for memeber 'Attribute3' (screenshot1.png). There is a button 'Remove p4' that changes the datasource by removing one member. After that, I call the api 'UpdateData'. The result is that the pivot data is correctly updated (screenshot2), the network call to 'members' returns the correct values (screenshot3), but if I open the filter mask I still see Member p4 (screenshot4).
Could you please resolve this issue?
Thanks in advance
Ilaria

1 answer

Public
Nadia Khodakivska Nadia Khodakivska Flexmonster January 20, 2023

Hello, Ilaria,

Thank you for reaching out to us and providing us with a sample project.

Kindly note that it is not expected that the data structure is changed in the runtime. That is why the "p4" member is present in the filter view after it was removed using the updateData API call. For such a use case, we suggest using the following approach:

  1. Use the clear API call to clear the component's data and view.
  2. Set a report with the new dataSource object using the setReport API call.

For example:

function changeDataSource() {
  const dataSource = {
    type: "api",
    url: "https://localhost:44362/api/cube",
    index: "Members",
  };
  pivot.clear();
  pivot.setReport({
    dataSource,
    slice: {
      columns: [{
        SourceColumnIndex: -1,
        uniqueName: "[Measures]",
        sortOrder: [],
      }, ],
      measures: [{
          SourceColumnIndex: -1,
          uniqueName: "Measure1",
          aggregation: "sum",
        },
        {
          SourceColumnIndex: -1,
          uniqueName: "Measure2",
          aggregation: "sum",
        },
      ],
      rows: [{
        SourceColumnIndex: -1,
        uniqueName: "CODE_3",
        caption: "Attribute3",
        sortOrder: [],
      }, ],
      formats: [{
        name: "",
        maxDecimalPlaces: 2,
      }, ],
    },
  });
}

Please let us know if it works for you. Feel free to contact us if other questions arise.

Kind regards,
Nadia

Please login or Register to Submit Answer