Transfer Data from Subview to Form's textbox where the mouse cursor is placed.


Hi All,

 

I have a toolbar button "Insert Name" on the Form and on the click this button I am opening a subview list, and on the double click of any list item I am closing the Subview. 

 

(Reffred this : https://community.k2.com/t5/K2-blackpearl/Transfer-Data-from-Subview-to-Form/td-p/99748)

 

On the Form I have written a rule like "When the Subview is closing" setting the propertie of textbox and appending the Name which user just selected from subview.

 

So for everything is fine. But my requirnment is - For a selected Name, if the user's cursor is within the  Form's TextBox, insert the Name value where the cursor is.  If the user's cursor is not within the Form's TextBox, then insert the Name value at the end of the text within the From's TextBox.

 

Please suggest somthing to achive this, how will I copy the text at Cursor position.

 

Thanks

Shubh


2 replies

Userlevel 5
Badge +16

Hi Shubh,


 


I was able to implement something similar to this.


 


I used the following script to get the cursor position and send the value to a data label on my view


 


 


<script>
var position = document.getElementById('TextBoxID').selectionStart;
$("[name='dlPosition']").SFCLabel('option', 'text', position);
</script>

Then design the following expression to set the user name according to the position value 


 



 


This might require some modifications as I haven't done much testing.


 


Please see attached video (open with IE)


 


 

Userlevel 5
Badge +16

Hi Shubh,


 


As far as I know, K2 doesn't catch the value of the Datalable if you set it using the methods .text()/.html() ..etc .


That's why I used the following which I believe it works:


 


 


$("[name='DataLabelName']").SFCLabel('option', 'text', cursorPos);

 


 

Reply