Skip to content
Aside

So I came across a client requirement that basically meant I was going to have to make all controls disabled in the onLoad event of the form with script.  No problem right?  Just get all the controls set disabled to true, and BAM!  Only problem is there are subgrids on the forms, and they need to be disabled as well, and there is no supported way to really do this.  The other major issue is that subgrids don’t actually show up in the controls collection in the onLoad event (as of 3/3/2014). 

Well, how to get around this?  The old trick of setting the subgrid span to disabled doesn’t work anymore (damn), so I looked into the disabled subgrid html on a Read Only form. Best I can tell, the disabling is being handled server-side and the main difference is the add and list expand buttons just aren’t rendered for a disabled grid.

OK, well with a little unsupported jQuery magic, I can remove the buttons.  The issue I had then was that the subgrids not being in the collection onLoad.  To get around that, I used setInterval to continuosly loop until the subgrids loaded and I could get them using Xrm.Page.  It doesn’t really make the form read only, of course, but it “fakes” it pretty well.  The code is below.

 

 

var intervalId;

function makeReadOnly()

{

    try

    {

        var subgridsLoaded = false;

        Xrm.Page.ui.controls.get().forEach(function (control, index)

        {

            if (control.setDisabled && Xrm.Page.ui.getFormType() != 3)

            {

                control.setDisabled(true);

            }

            else

            {

                removeAddButtonFromSubGrid(control);

                subgridsLoaded = true;

            }

        });

 

        if ($(“div[id$=’_crmGridTD’]”).length > 0 && !subgridsLoaded)

        {

            intervalId = setInterval(function ()

            {

                var subgridsArr = Xrm.Page.getControl(function (control, index)

                {

                    return control.getControlType() == ‘subgrid’;

                });

 

                subgridsArr.forEach(function (control, index)

                {

                    removeButtonsFromSubGrid(control);

                });

            }, 500);

        }

    }

    catch (e)

    {

        alert(“makeReadOnly() Error: ” + e.message);

    }

}

 

function removeButtonsFromSubGrid(subgridControl)

{

    if (intervalId)

    {

        $(‘#’ + subgridControl.getName() + ‘_addImageButton’).css(‘display’, ‘none’);

        $(‘#’ + subgridControl.getName() + ‘_openAssociatedGridViewImageButton’).css(‘display’, ‘none’);

        clearInterval(intervalId);

    }

}

Political Reason – Hopefully not an oxymoron….

Where did we go wrong?

I’ve heard so many people ask that in the United States in regards to our political system over the last few years. The intention of this site is to address that question, and propose solutions to some of the pressing issues that face us today. This site will never obsess over ideology; to put beliefs over reason and results. It will freely bash all political parties, and both sides of the political spectrum.

Compromise.

In a modern nation with a sizable population it will be impossible to completely satisfy everyone’s demands.  Environmentalists will never see eye to eye with mining interests, gun nuts will never agree with safety Nazis, and god forbid I bring up abortion.  Some of the content on this site will not necessarily reflect my own views 100%, but will instead be a suggestion as to what is the best possible compromise.

Integrity

Misuse of statistics, ignorance, and outright lies have infected the political discourse.  One thing that will be insisted upon throughout the publishing of posts on this site is integrity and accountability.  Facts must be backed up with references, and any discrepancies found will be published and acknowledged.

The Failure of Political Parties

The main political parties in the United States have largely failed both their constituencies and the population at large.  This sentence is the last time the words “Democrat” or “Republican” will be printed on the site.  Too much energy is being burned trying to tear the other guy down and build our side up for me to advocate that political parties continue to exist, let alone one over the other.  A “team” mentality has infected our process.  Politics is not a spectator sport. 

Respect

The team mentality has led to a lack of respect.  When we no longer are weighing the issues and soberly choosing one course of action over another but rooting for our guy, respect and civility are lost.  Discourse on this site will remain on an intellectual level.

How can we go right?

I hope that the articles that will be appearing on this site over time will help spread ideas, not always my own, that can have a positive affect on politics and policy.