Skip to main content

Hello,

 

we have a problem with the picker controll. The "normal" way to work with it seems to populate the picker control one time with the whole amount of data and then if the user types in a string, the control resolves it and gives you a list of possible results.

 

We have an appliance where this is not possible because the total ammount of data seems to be way too much for the control (380.000+ entries of data) but our SmartObject, that gets the data is able to provide only a subset of data if it gets the string, that the user typed in to "resolve"...

Without any "filtering" the SmartObject needs 20 Minutes to provide all data, when you give him 2 digits as an intial filter (let's say you want only the numbers starting from "09") the speed is greatly increased to some 10 seconds. For every other additionally provided digits it comes down to few seconds to almost none notable delay.

 

But my problem is: it seems to be impossible to get the string that the user typed into the picker control... Is there any was to get the information *and* make it usable in rules for the control?

I was thinking of two data labels. One is set to "literal" but disabled and one should provide the information.

I a rule "when picker is resolving" I want to enable the "script data label" that runs a script that takes the typed in string and places it into the second data label. Then it shoudl disable the "script data label" and fire the populate method of the control with the input of the second data label.

 

Is this possible in any way? Or is there a better solution to it? (the best would be that K2 provides the string within designer but it seems not to be possible...)

 

regards,

Johann

I did some research bymyself and found the following points:

 

a disabled literal data label is still executed. You have to empty the text and fill the text at runtime in a rule and it gets executed.

 

editing the (inner) html of a data label does NOT change the internal (K2) value of a datal label :-(

 

any hints to to deal with this problem?


Found a Solution by myself:

 

<script>
$("[name='YOUR DATA LABEL NAME IN K2 DESIGNER']").SFCLabel('option', 'text','YOUR NEW VALUE');
</script>

 

a similar aproach also works for Textboxes:

<script>
$("[name='YOUR DATA LABEL NAME IN K2 DESIGNER']").SFCTextBox('option', 'text','YOUR NEW VALUE');
</script>

 


and I also found a solution to get the input Text from the picker control:

 

<script>
var els = document.getElementById('ID from Picker').getElementsByClassName('editable-area');
var IT = '';
Array.prototype.forEach.call(els, function(el) {
IT = el.innerHTML;
});
$("[name='Data Label1']").SFCLabel('option', 'text', IT);
</script>


Now I have to find a way to define different IDs for our three stage system (DEV, QA and PROD) because the IDs of the HTML tags are different for each stage 😞

Reply