Skip to main content

Notifications

Announcements

No record found.

Service | Customer Service, Contact Center, Fie...
Answered

Dynamcis Portal - Get subgrid.length to show/hide create button

Posted on by

Hi

I have a Entity Form (Basic Webform) with 3 related subgrids (subgrid A, B, C). Is there a way to get table lenght from subgrid A via subgrid-schema-name that i set in the form options in dynamics? After i get the lenght from subgrid A, i will hide the create button if length is bigger then 0. We want to prevent the user from creating more than one record for subgrid A.

Is there a way to solve this problem?

To hide the button I already have a javascript function, but every "create-button" has the same id, and in my test the hidefunction hided all create button from all subgrids. I cannot limit the hide-function to subgrid A.

here is my code to hide "create-button":

$(".grid-actions").hide();
i hope someone can help
Thanks in advance
  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Dynamcis Portal - Get subgrid.length to show/hide create button

    Hi Partner,

    You should use following code to hide button of sub-grid in portal:

    $(document).ready(function(){
    
        // hide create button once sub-grid contains a record
        $(".entity-grid").on("loaded", function () {
            var tBody = $(this).find("tbody")
            if(tBody.length > 0)
            {        
                $(".grid-actions").hide();
            }
        });
    });

    However, if your form contains multiple subgrids.. you might consider finding your sub-grid by index for example:

    var subgridA = $(".entity-grid").eq(0);

    var subgridB = $(".entity-grid").eq(1);

    var subgridC = $(".entity-grid").eq(2);

    Regards,

    Leah Ju

    Please mark as verified if the answer is helpful. Welcome to join hot discussions in Dynamics 365 Forums.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans