web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id : WrnW9B6+/kCTBD7BTdzUNF
Power Apps - Microsoft Dataverse
Unanswered

Editable Grid - Read Only Column based on Linked Entity

Like (0) ShareShare
ReportReport
Posted on 10 Jun 2024 12:33:23 by 4

Hello

 

I have an editable grid control on a form within a model driven app and I can use JavaScript to set a column as read only using setDisabled(true) based on the value of another column in the view.  However, I'm now trying to reference a column from a related entity by adding it to the view.  When I do this I can see the column on the sub grid but I cannot seem to call the new column within JavaScript.  Does anyone know if this is possible?

 

Thanks

Graeme

Categories:
I have the same question (0)
  • GraemeCash Profile Picture
    4 on 17 Jun 2024 at 10:50:06
    Re: Editable Grid - Read Only Column based on Linked Entity

    Hello

     

    I am using the Power Apps grid control which allows a record's child records to be edited.  The aim is set the quarter fields to read only depending if the quarter has been locked for editing.  Ideally, I wanted to use the quarter lock field from the parent entity and add that to the grid to be picked up by the JavaScript but I could not get it to work.  I had to resort to adding the same quarter lock field to the child entity and use a flow to update the record.  Below is the code I have added in...

     

    function lockQuarterActualsOnGrid(executionContext) {
        let gridContext = executionContext.getFormContext();

        //Get quarter controls
        let q1 = gridContext.getAttribute('sa_q1');
        let q2 = gridContext.getAttribute('sa_q2');
        let q3 = gridContext.getAttribute('sa_q3');
        let q4 = gridContext.getAttribute('sa_q4');

        //Get quarter locks
        let q1Locked = gridContext.getAttribute('sa_q1locked').getValue();
        let q2Locked = gridContext.getAttribute('sa_q2locked').getValue();
        let q3Locked = gridContext.getAttribute('sa_q3locked').getValue();
        let q4Locked = gridContext.getAttribute('sa_q4locked').getValue();

        //Lock each quarter as necessary
        if (q1Locked) {
            q1.controls.get(0).setDisabled(true);
        }
        else {
            q1.controls.get(0).setDisabled(false);
        }
       
        if (q2Locked) {
            q2.controls.get(0).setDisabled(true);
        }
        else {
            q2.controls.get(0).setDisabled(false);
        }

        if (q3Locked) {
            q3.controls.get(0).setDisabled(true);
        }
        else {
            q3.controls.get(0).setDisabled(false);
        }

        if (q4Locked) {
            q4.controls.get(0).setDisabled(true);
        }
        else {
            q4.controls.get(0).setDisabled(false);
        }

    }



    Thanks

  • MichaelFP Profile Picture
    1,833 Super User 2025 Season 2 on 11 Jun 2024 at 11:40:04
    Re: Editable Grid - Read Only Column based on Linked Entity

    Can you share the piece of the code that you are trying to execute?

  • GraemeCash Profile Picture
    4 on 10 Jun 2024 at 12:51:36
    Re: Editable Grid - Read Only Column based on Linked Entity

    I'm calling the function from the OnRecordSelect event on the grid.

  • MichaelFP Profile Picture
    1,833 Super User 2025 Season 2 on 10 Jun 2024 at 12:45:44
    Re: Editable Grid - Read Only Column based on Linked Entity

    in which event are you set the setDisable method?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Telen Wang – Community Spotlight

We are honored to recognize Telen Wang as our August 2025 Community…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 637 Most Valuable Professional

#2
stampcoin Profile Picture

stampcoin 570 Super User 2025 Season 2

#3
Power Apps 1919 Profile Picture

Power Apps 1919 473

Featured topics

Loading started
Loading complete