dynamics-crmdynamics-crm-onlinedynamics-crm-365-v9

Can't disable field subgrid with javascript


I have 2 subgrid, one is selected mid-tid, and the other one is all-mid-tid. and i want to disable field on mysubgrid , so after some search on the internet i found this script

function setGridDisableWO(context) 
{
    context.getFormContext().getData().getEntity().attributes.forEach
    (
        function (attr) 
        {
            var NamaId = attr.getName();
            if(NamaId == "mjt_store" || NamaId == "mjt_pot" || NamaId == "mjt_id" || NamaId == "mjt_partner" || NamaId == "mjt_mid" || NamaId == "mjt_tid" || NamaId == "mjt_status_pot_facility" || NamaId == "createdon" || NamaId == "mjt_facility")
            {
                attr.controls.forEach(function (c) 
                {
                    c.setDisabled(true);
                })
            }
        }
    );
}

this script is working, but the problem is , it only work on my all-mid-tid subgrid, in my other subgrid its not working. when i'm try to debug it and set breakpoint its not even stop on my breakpoint, both subgrid has same entity and field name its realy strange why only one is working, i'm already double check if i have misspeled my function or my event on subgrid but i didn't make any mistake, any suggestion here ?


Solution

  • Why dont you try putting the same class name in both the grids and Call that class in javascript and setDisable as true or False as prefered?