Word document: copy a document into another one

In this article we will present a broker we have developed. This service allows us to copy the entire content of a word document and place it within a specific content control of another word document.

Insert a value into a K2 control via JQuery

Sometimes there are operations that are not feasible or hardly feasible on K2. But that we can do via JQuery, only we need to store in a K2 control the result that the JQuery code returns. How to do it?  😕  

Let’s imagine this case: We have a list view containing the list of students of a class, and we want to display the first three students of a list without user interaction after loading the view. As below:

Insérer une valeur dans un contrôle K2 via JQuery

  • How to do it without user interaction?  😯 
  • Answer: By writing in a K2 control via JQuery.  😉

We will use JQuery and we will do it in two steps:

  1. Retrieve the first three rows of the list view
  2. Insert the retrieved rows in a K2 control (DataLabel)
  3. Trigger the JQuery code snippet

Let’s go !!!  😎

  1. Retrieve the first three rows of the list view

First we should add a DataLabel on the view to identify the view (in our case we will call it dl_FirstStudentName). Then from this Data Label we will use this piece of code :

a) Recovery of the 1st line

$('span[name="dl_FirstStudentName"]').closest('.grid-toolbars').siblings('.grid-body').find('.grid-body-content tr:first td:first span').text()
Récupération de la 1er ligne

 

b) Recovery of the 2nd line

$('span[name="dl_FirstStudentName"]').closest('.grid-toolbars').siblings('.grid-body').find('.grid-body-content tr:nth-child(2)  td: first span').text()
Récupération de la 2ième ligne

 

c) Recovery of the 3rd line

$('span[name="dl_FirstStudentName"]').closest('.grid-toolbars').siblings('.grid-body').find('.grid-body-content tr:nth-child(3)  td: first span').text()
Récupération de la 3ième ligne

 

  1. Insert the retrieved rows in K2 control (DataLabel) :

Here is the JQuery code snippet to insert text into a DataLabel :

$("[name='dl_FirstStudentName']").SFCLabel('option', 'text', XXXXX);
Insérer du texte dans un Data Label

The value XXXXX will be replaced by the recovery code of the first three lines which will give us the following code:

<script>$("[name='dl_FirstStudentName']").SFCLabel('option', 'text', 
'1-) ' + $('span[name="dl_FirstStudentName"]').closest('.grid-toolbars').siblings('.grid-body').find('.grid-body-content tr:first td:nth-child(2) span').text() + "\n" + 
'2-) ' + $('span[name="dl_FirstStudentName"]').closest('.grid-toolbars').siblings('.grid-body').find('.grid-body-content tr:nth-child(2) td:nth-child(2) span').text()+ "\n" + 
'3-) ' + <script>$('span[name="dl_FirstStudentName"]').closest('.grid-toolbars').siblings('.grid-body').find('.grid-body-content tr:nth-child(3) td:nth-child(2) span').text());</script>

Let’s insert on our view a Data Label (named dl_JQuery in our case), then create an expression containing expression below this value:

Insérer une valeur dans un contrôle K2 via JQuery : Expression

  1. Trigger the JQuery code snippet

Cette phase nous permet lancer l’exécution de notre code, pour ce faire nous utiliserons une règle sur K2 :Insérer une valeur dans un contrôle K2 via JQuery: Règle

First transfer data is used to empty the Data Label dl_JQuery

Insérer une valeur dans un contrôle K2 via JQuery: Règle

Second transfer data is used to empty the Data Label dl_JQuery

Insérer une valeur dans un contrôle K2 via JQuery: Règle

So we can call our rule when initializing the view:

Insérer une valeur dans un contrôle K2 via JQuery: Règle

We obtain this result

Insérer une valeur dans un contrôle K2 via JQuery

Word content control: Replace its content by another word content control

We will see how to replace the content of a content control of a word document from its K2 application. Let us consider that we have two word documents (D1 and D2). Each document have a content control C1 and C2 respectively. Here we will see how to replace the content of C1 by the content of C2 while maintaining the style. Indeed, the integration of a service that would do this is interesting.
Read more

Broker: merge two word documents on K2

Merging two word documents via the K2 application is an interesting feature. Indeed, the integration of a service that merges two word documents by generating another document is very interesting 🙂☝.
We present you a solution among one of the solutions developed in other articles on the same subject.

Read more

Add pagination on K2 list view editable

Hello !

I’ll  present you an interesting tutorial  😎 : the pagination of an editable list view on K2 . Indeed, K2 allow to add the pagination on a list view that can not be editable. But it not possible to add the pagination on an editable list view. Truce of chatter let us go to the heart of the matter.  😉 Read more

Clickable Data Label: open a pop-up

K2 controls that you do not have the “clicked ” event (such as Data Label, Label, HyperLink, etc.) and do not give the possibility to make operations during the click. However, in some cases we would want to make a clickable data label. For example use a Data Label, Label or HyperLink to open a Pop-Up. So how do you open a Pop-Up at a click on it for example 😬😬😬? Don’t panic!!!☝😌.

In this tutorial we will show you how to make a DataLabel control clickable so that it opens a Pop-Up. The process is the same for making a HyperLink control type. Read more