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 / 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 / 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-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 / k2-ci-demo-deploy.ps1
Created March 12, 2018 14:53
K2 Automatic Deployment
#Adds the PowerShell Deployment snapin.
add-pssnapin SourceCode.Deployment.PowerShell
#Scripts the deployment of a package
Deploy-Package $(System.DefaultWorkingDirectory)/K2-CI-Demo-CI/$(Build.BuildNumber)/ExpenseClaim.kspx $(System.DefaultWorkingDirectory)/K2-CI-Demo-CI/$(Build.BuildNumber)/ExpenseClaim.xml
@dudelis
dudelis / k2-listbox-option-draggable.js
Created March 6, 2018 11:31
K2: Draggable listbox options
//Converting the 'text' into '{text}' for the Email Templating placeholders
var dragListBox = function(ev) {
ev.dataTransfer.setData("text",'{' + ev.srcElement.text + '}');
};
//Adding html attributes to make the inner items draggable
$('div[name="NameOfYourListBox"]')
.find('.optionwrapper')
.find('.option')
.attr('draggable', 'true')
.attr('ondragstart', 'dragListBox(event)');
@dudelis
dudelis / k2-ci-demo-package.ps1
Created February 28, 2018 11:08
K2 Automatic Build
param([string]$appName, [string]$categoryPath)
if(-not($appName)){ Throw "You must provide the name for your application"}
if(-not($categoryPath)){ Throw "You must provide the path for your application category"}
#01. Create a folder for the output
New-Item -ItemType Directory -Force -Path $PSScriptRoot\PND
#02. Create a package
Import-Module $PSScriptRoot\Assemblies\K2Field.Powershell.Module.dll -Verbose -Force
@dudelis
dudelis / k2-listcolumn-highlight.html
Last active March 25, 2018 18:54
K2: Highlighting a column in a List View
<!--Insert the snippet below in a Literal Datalabel -->
<style type="text/css">
div[name="View Name"] .grid-body tbody td:nth-child(%ColumnNumber%) {
background: #FFFACD !important
}
</style>
@dudelis
dudelis / Excel-GetCellValue.cs
Created February 26, 2018 13:52
Excel - Get cell value (OpenXML)
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;
public static string GetCellValue(string fileName, string sheetName, string addressName)
{
string value = null;
using (SpreadsheetDocument document = SpreadsheetDocument.Open(fileName, false))
{
WorkbookPart wbPart = document.WorkbookPart;
Sheet theSheet = wbPart.Workbook.Descendants<Sheet>().Where(s => s.Name == sheetName).FirstOrDefault();
@dudelis
dudelis / k2-checkbox.html
Last active March 25, 2018 18:54
K2: Checkbox html
<!-- Checked -->
<label class="input-control checkbox checked" data-defaultvalue="false">
<span class="input-control-img"></span>
</label>
<!-- Not checked -->
<label class="input-control checkbox" data-defaultvalue="false">
<span class="input-control-img"></span>
</label>