Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Can't disable field subgrid with javascript

Posted on by Microsoft Employee

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 ?





*This post is locked for comments

  • Suggested answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Can't disable field subgrid with javascript

    Do you see any errors in console? If you have registered it on an event then when the at event is triggered the breakpoints will hit.

  • Suggested answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: Can't disable field subgrid with javascript

    Hi Rida ,

    If you your code is working for one grid then its should work for other editable grid as well .Is there any other differences you set while configure editable grid  except field name while configure editable grid.

    In addition try to implement different function name .

    Refer below  -

    bettercrm.blog/.../disable-columns-in-editable-grid

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Can't disable field subgrid with javascript

    thats the problem, the code is not even stop in the breakpoint, but for my other subgrid its catch the breakpoint. Thats what make me very confused

  • RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Can't disable field subgrid with javascript

    So did you select a record on your second grid to trigger the event which disables the columns? Chck developer tool (F12) and see if there are any errors?It any error, check or share screenshot

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Can't disable field subgrid with javascript

    mid-tid, & all-mid-tid its my subgrid name, and yes both of them on the same form. i registered this script onrecordselected event

  • RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Can't disable field subgrid with javascript

    What do you mean by mid-tid, & all-mid-tid? Are these 2 subgrid on the same form? Where/ how you have registered this script?

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