microsoft / PowerApps-Samples

Sample code for Power Apps, including Dataverse, model-driven apps, canvas apps, Power Apps component framework, portals, and AI Builder.

Home Page:https://docs.microsoft.com/powerapps

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Component is not displayed until Refresh clicked on command menu

LozzieDuff opened this issue · comments

When the ModelDrivenGrid solution is published and executed in PowerApps, nothing is displayed until Refresh is clicked on the command menu.

Maybe this is by design?

If not, this can be fixed by inserting ...

this.context.parameters.records.refresh();

... at the end of the public init method.

@LozzieDuff Are you asking about one of our code samples? If so, which one?

@phecke Hi there, yes, the ModelDrivenGridControl ...

https://github.com/microsoft/PowerApps-Samples/tree/master/component-framework/ModelDrivenGridControl

I downloaded and installed it as is (great demonstrator, btw), but it didn't appear to show any data. Hitting browser refresh didn't help. Hit the command bar Refresh and whoosh, there it was. Stepped through the code (I'm a newbie with the JSX, React, PCF frameworks/stacks/whatever(!), more dotnet and vanilla JavaScript experience) but eventually took a punt on adding -- this.context.parameters.records.refresh(); -- at the end of the public init method. That worked.

Whether it is the right thing to do or if I've missed a bit out of newbie-ness I don't know!

If it is a valid "fix", can I have a go at branching and pull request the "fix" in and all that jazz? My first contribution - break my Github virginity, so-to-speak!

For me the component is loading but data isn't, but when I click on "Refresh" in the command bar it starts showing data. Even clicking on sorting shows the data.

  • During page load

noRecordsFound

  • After clicking "Refresh" or "Sorting"

image

Yep, that's the issue I experienced.

As said, try adding: this.context.parameters.records.refresh(); -- at the end of the public init method.

@LozzieDuff
Are you proposing that this code:

this.context.parameters.records.refresh();

Should be placed after this line in the sample?

So that the init method: looks like this:

    public init(
        context: ComponentFramework.Context<IInputs>,
        notifyOutputChanged: () => void,
        state: ComponentFramework.Dictionary,
        container: HTMLDivElement,
    ): void {
        this.notifyOutputChanged = notifyOutputChanged;
        this.container = container;
        this.context = context;
        this.context.mode.trackContainerResize(true);
        this.resources = this.context.resources;
        this.isTestHarness = document.getElementById('control-dimensions') !== null;
        this.context.parameters.records.refresh();
    }

Also, are you using the instructions for this sample provided here: Tutorial: Creating a model-driven app dataset component?

Yes that's correct.

@LozzieDuff
Thanks. I've created a workitem to review this tutorial with focus on those steps.

3037743