Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
jenriquez
Contributor III
Contributor III

toggle the qLoked value in Qlik Sense Extension

Hi, can someone help me on getting the new value of qLocked state in Qlik Sense Extension.

I have if statement for getting the value of qLocked, but when I have a change the value it cant reflect on my paint method.

Can someone help me with the right code syntax to toggle the selected value without reloading the sheet.

Thanks.

Labels (2)
1 Solution

Accepted Solutions
ArnadoSandoval
Specialist II
Specialist II

Hi @jenriquez 

You are handling the qLocked improperly;  It is an attribute of the mySelectedFields object; and it is not a true/false attribute, it is present as true when the field is locked in the User Interface, and it is not present at all the the field is not lock.

The screenshot below was taken from the extension's console (I am using a version of your extension, one you posted the other day); at the UI I selected and locked the Customer field, while with the FIELDS field I just selected one value without locking it; the second screenshot show those selections: 

ShowValues-06.png

ShowValues-05.png

This code reach the field qLocked, but you should improve the logic to handle the scenario when the field is not locked.

console.log('locked? ', mySelectedFields[i].qLocked);

Hope this helps,

Arnaldo Sandoval
A journey of a thousand miles begins with a single step.

View solution in original post

2 Replies
ArnadoSandoval
Specialist II
Specialist II

Hi @jenriquez 

You are handling the qLocked improperly;  It is an attribute of the mySelectedFields object; and it is not a true/false attribute, it is present as true when the field is locked in the User Interface, and it is not present at all the the field is not lock.

The screenshot below was taken from the extension's console (I am using a version of your extension, one you posted the other day); at the UI I selected and locked the Customer field, while with the FIELDS field I just selected one value without locking it; the second screenshot show those selections: 

ShowValues-06.png

ShowValues-05.png

This code reach the field qLocked, but you should improve the logic to handle the scenario when the field is not locked.

console.log('locked? ', mySelectedFields[i].qLocked);

Hope this helps,

Arnaldo Sandoval
A journey of a thousand miles begins with a single step.
jenriquez
Contributor III
Contributor III
Author

hi @ArnadoSandoval 

I'm using this code to toggle ng button, and yup after reload the sheet the button will display the right button which is the button I call from else but when I locked and not reloading the page, the paint method did not get the new value to replace the old value, it keeps display the value after reloading.

if (mySelectedFields.qLocked == true)
{
	html += '<button id="unlock_button" style="display: none" onClick="(function(){var app = gQlik.currApp();app.unlockAll();})();" class="btn-lock-unlock lui-icon lui-icon--unlock"></button>'
}
else
{
	html += '<button id="lock_button" onClick="(function(){var app = gQlik.currApp();app.lockAll();})();" class="btn-lock-unlock lui-icon lui-icon--lock"></button>'
	html += '<button id="clearAll" onClick="(function(){var app = gQlik.currApp();app.clearAll();})();" class="btn-lock-unlock lui-icon lui-icon--clear-selections"></button>';
}