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 :
Service | Customer Service, Contact Center, Fie...
Answered

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

(0) ShareShare
ReportReport
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
I have the same question (0)
  • Verified answer
    Community Member Profile Picture
    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

Responsible AI policies

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

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Service | Customer Service, Contact Center, Field Service, Guides

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 49 Super User 2025 Season 2

#2
MVP-Daniyal Khaleel Profile Picture

MVP-Daniyal Khaleel 46

#3
CU23101130-0 Profile Picture

CU23101130-0 17

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans