Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Using Granite condition to make the field read-only

Avatar

Avatar
Validate 1
Level 1
test1234567
Level 1

Likes

0 likes

Total Posts

10 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
test1234567
Level 1

Likes

0 likes

Total Posts

10 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile
test1234567
Level 1

11-01-2021

Hello All - I have a use-case to make the checkbox readonly in a dialog based on sling:resourceType using granite:RenderCondition. Can someone advise on this?

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Establish
MVP
Anudeep_Garnepudi
MVP

Likes

275 likes

Total Posts

320 posts

Correct Reply

87 solutions
Top badges earned
Establish
Ignite 1
Give Back 5
Give Back 3
Give Back 10
View profile

Avatar
Establish
MVP
Anudeep_Garnepudi
MVP

Likes

275 likes

Total Posts

320 posts

Correct Reply

87 solutions
Top badges earned
Establish
Ignite 1
Give Back 5
Give Back 3
Give Back 10
View profile
Anudeep_Garnepudi
MVP

11-01-2021

@test1234567 

As @kunal23  said granite:renderCondition is server side implementation. Only if the condition satisfies the field will be rendered on to the dialog. The name renderCondition say it all, based on condition field will be rendered. Use below listener to disable the checkbox.

(function ($, $document, Ga) {

    $document.on("dialog-ready", function() {
		let checkbox = $("coral-checkbox[name='./checkbox']");
        if (window.location.pathname.indexOf("/content/test/") >= 0) { //your condition
			checkbox[0].disabled = true;
        }
    });

})(jQuery, jQuery(document), Granite.author);

- AG

Answers (1)

Answers (1)

Avatar

Avatar
Validate 10
MVP
kunal23
MVP

Likes

166 likes

Total Posts

565 posts

Correct Reply

172 solutions
Top badges earned
Validate 10
Validate 1
Ignite 3
Ignite 1
Give Back 50
View profile

Avatar
Validate 10
MVP
kunal23
MVP

Likes

166 likes

Total Posts

565 posts

Correct Reply

172 solutions
Top badges earned
Validate 10
Validate 1
Ignite 3
Ignite 1
Give Back 50
View profile
kunal23
MVP

11-01-2021

You can hide a check box using a render condition and not make it read only. Render conditions are evaluated server side by Granite UI framework to show or hide a UI component. 

You can write a custom render condition to hide the checkbox based on the resource type. For more details see the following blog- http://www.nateyolles.com/blog/2016/07/aem-granite-custom-render-conditions