Skip to content

Instantly share code, notes, and snippets.

@dudelis
dudelis / dropdown-duplicates-remove.js
Last active December 2, 2017 21:44
How to remove duplicates from a dropdown #k2 #k2-blackpearl #k2-smartforms #js
//In order to make it work you need to replace YourControlName with the name of your dropdown.
//This piece of code assumes, that you have only 1 dropdown on the form with this name. In any case only the first instance will be taken.
var dropdownControlPath = "Controllers/Controller/Controls/Control[@Name='YourControlName']";
var dropDownControlControl = $sn($xml(__runtimeControllersDefinition), dropdownControlPath);
var contrId = dropDownControlControl.getAttribute('ID');
var ddl = $('#' + contrId + '_DropDown');
var items = $(ddl).dropdown('option', 'items');
for( var i = 0; i < items.length; i++){
@dudelis
dudelis / script.js
Last active March 4, 2019 14:34
K2 Smartforms: How to make Textarea resizable
$(document).ready(function(){
$('textarea').each(function(index, obj){
$wrapper = $(obj).closest('.input-control.text-input');
var width = $wrapper.width();
$wrapper.css('width', '');
$(obj).css('width', width + 'px');
$(obj).resizable();
});
});
@dudelis
dudelis / k2-listview-checkboxes.js
Last active May 4, 2018 20:50
K2: Select Listview rows with checkboxes
//You need to do the following for the code to work:
//1. Add Literal datalabel to the list view and call it 'dlblScript'.
//2. Add a new column into the list view, add literal datalabel there and add a piece of the following html inside:
<input type="checkbox" class="custom-box"/>
//3. Add the following js into the dlblScript:
<script>
var contentTable = $("span[name='dlblScript']").closest('.grid').find('.grid-content-table')[0];
var observer = new MutationObserver(function(mutations){
$(contentTable).find('.custom-box').each(function(i, val){
if ($(this).prop('checked')){
@dudelis
dudelis / k2-listview-headers-rotate.html
Last active December 7, 2018 12:07
K2 Smartforms: How to rotate ListView headers
<style>
div[name="viewTestVerticalColumnHeader"] .grid-column-header-table tr {
height: 100px; /* This value defines the height of your header*/
white-space: nowrap;
}
div[name="viewTestVerticalColumnHeader"] .grid-column-header-table .grid-column-header-cell {
transform:
translate(25px, -5px) /* This numbers you have to change to move the header after rotation*/
rotate(315deg); /* This defines the angle of rotation. - 45 is really 360 - 45 */
width: 140px!important; /* This value defines if you see all the text or some of the characters*/
@dudelis
dudelis / ssrs-project-deployment.ps1
Last active December 5, 2017 21:53
SSRS - Deployment of all the Reports, DataSources, DataSets and fixing the DataSoure bindings.
Function Deploy-SSRSProject([string]$ssrsServer, [string]$rdlPath, [string]$ssrsFolder, [string]$schema = "https"){
#Set variables with configure values
$reportPath ="/" # Rool Level
$DataSourcePath = "/Data Sources" #Folder where we need to create DAtasource
$DataSet_Folder = "/Datasets" # Folder where we need to create DataSet
$IsOverwriteDataSource = 0
$IsOverwriteDataSet = 1
$IsOverwriteReport = 1
$webServiceUrl = $schema + "://$ssrsServer"
@dudelis
dudelis / k2-button-click-upon-enter.js
Last active January 9, 2018 10:05
K2 Smartforms: How to click a button upon enter key from textbox
<script>
$('.SFC.SourceCode-Forms-Controls-Web-TextBox').keypress(function (e) {
var key = e.which;
if(key == 13)
{
var value = e.currentTarget.value;
$(e.currentTarget).SFCTextBox('option', 'text', value);
$('a[name ="NameOfYOurButton"]').click();
return false;
}
@dudelis
dudelis / remove-velocity-signup-prompt.js
Created December 13, 2017 10:38
How to remove annoying Sign Up prompt on velocity-it.com
//Open Developer tools and run this in the Console
document.getElementsByClassName("onp-sl-outer-wrap")[0].remove();
document.getElementsByClassName("onp-sl-blur-area")[0].style.filter = '';
@dudelis
dudelis / k2-folio-update.ps1
Created December 18, 2017 15:36
K2: Update Process Instance folio
Function Update-Folio ([int]$procInstId, [string]$folio){
if(-not($procInstId)) { Throw "You must supply a value for -procInstId" }
if(-not($folio)) { Throw "You must supply a value for -folioName" }
Add-Type -AssemblyName ('SourceCode.Workflow.Client, Version=4.0.0.0, Culture=neutral, PublicKeyToken=16a2c5aaaa1b130d')
$k2con = New-Object -TypeName SourceCode.Workflow.Client.Connection
$k2con.Open("localhost")
$procInst = $k2con.OpenProcessInstance($procInstId);
$procInst.Folio = $folio;
$procInst.Update()
@dudelis
dudelis / k2-startdev-asaservice.ps1
Created January 2, 2018 22:31
K2: Run development license as a service
# Remove the existing K2 Blackpearl Server service
sc.exe delete "K2 blackpearl Server"
# 2. Run nssm configuration
C:\NSSM\win64\nssm.exe install "K2 blackpearl Server"
@dudelis
dudelis / k2-viewheader-clickable.js
Last active March 25, 2018 18:54
K2: How to make the whole header view clickable (expand/collapse)
var headerClick = function(self) {
if(self){
$(self.currentTarget).find('a').click();
}
};
$('.grid-header').click(headerClick);