Deactivate mouse selection on kendo grid

Recently I had to disable mouse selection on a kendo grid which was already multi cell selectable. I had to disable this effect on a different event. Since kendo grid does not have this functionality supported at run time, I stumbled up on this and came up with the below solution. Hope it helps someone.

This can be done by adding a covering the kendo grid div with a transparent div element.

var kendoGrid= $(“#grid”);
var width = kendoGrid.eq(0).outerWidth();
var height = kendoGrid.eq(0).outerHeight();

var position = kendoGrid.offset();
$(“<div class=’cover’>”).css({
“width”: width,
“height”: height,
“position”: “absolute”,
“top”: position.top,
“left”: position.left
}).appendTo($(“body”));

JS Fiddle

Advertisements

App.Config Transformation for Windows Applications

In order to have app.config transformation working for windows application, have a separate configuration file for each of the required config, and then add the below lines of code to your project file.

<PropertyGroup>
<AppConfig>App.$(Configuration).config</AppConfig>
</PropertyGroup>

A tag team championship battle between Entity Framework, NuGet vs TeamCity, SQL Provider

Recently we have upgraded our entity framework through NuGet and had all our unit test cases passing locally. Everything started to fail on TeamCity build server and there was not much stack trace displayed in the build log. After looking into detailed unit test logs, I finally found out that we were having issue with Entity Framework cannot find SQL Provider.

After couple of hours of looking up on the web, I finally stumbled up on this awesome blog by Rob Lang where he describes each and every scenario to fix the problem. In my case adding the below block of code to ClassInitializer helped me out to fix the problem.

public void FixEfProviderServicesProblem()
{
//The Entity Framework provider type ‘System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer’
//for the ‘System.Data.SqlClient’ ADO.NET provider could not be loaded.
//Make sure the provider assembly is available to the running application.
//See http://go.microsoft.com/fwlink/?LinkId=260882 for more information.

var instance = System.Data.Entity.SqlServer.SqlProviderServices.Instance;
}

Hope this helps someone in future.

Regards,
Adi

Include artifacts in Team City E-Mail Notifier

If you have admin access to teamcity server, you can easily update the default email notification template to include artifacts of a build. This is how I did it.

Step1: Navigate to Team City _notifications folder. (in my case it was C:\ProgramData\JetBrains\TeamCity\config\_notifications\email)

Step2: Add below lines to build_failed.ftl and build_successful.ftl

<p>Build artifacts:</p>
  <#list build.artifactsDirectory.listFiles() as file>
    <a href="${webLinks.getDownloadArtefactUrl(build.buildTypeExternalId, build.buildId, file.name)}">${file.name}</a> (${file.length()}B)<br/>
  </#list>
Step3: Push a build and check your email 😉
This is how build_successful.ftl looked like after the addition.

<#– Uses FreeMarker template syntax, template guide can be found at http://freemarker.org/docs/dgui.html –>

<#import “common.ftl” as common>
<#import “responsibility.ftl” as resp>

<#global subject>[<@common.subjMarker/>, SUCCESSFUL] Build ${project.fullName} :: ${buildType.name} <@common.short_build_info build/></#global>

<#global body>Build ${project.fullName} :: ${buildType.name} <@common.short_build_info build/> successful ${var.buildShortStatusDescription}.
<@resp.buildTypeInvestigation buildType true/>
Agent: ${agentName}
Build results: ${link.buildResultsLink}

${var.buildCompilationErrors}${var.buildFailedTestsErrors}${var.buildChanges}
<@common.footer/></#global>

<#global bodyHtml>

Build ${project.fullName?html} :: ${buildType.name?html} successful
${var.buildShortStatusDescription}

<p>Build artifacts:</p>
<#list build.artifactsDirectory.listFiles() as file>
<a href=”${webLinks.getDownloadArtefactUrl(build.buildTypeExternalId, build.buildId, file.name)}”>${file.name}</a> (${file.length()}B)<br/>
</#list>
<@common.build_agent build/>
<@common.build_comment build/>
<br>
<@common.build_changes var.changesBean/>
<@common.compilation_errors var.compilationBean/>
<@common.test_errors var.failedTestsBean/>
<@common.footerHtml/>
</div>
</#global>

and here is a sample email containing build artifacts.

Build artifacts:
.teamcity (0B)
Project Report.pdf (2992569B)
Agent: Agent007

Link to TeamCity Documentation

script all objects of a database in sql server

Scripting all objects of a database in SQL Server can be done easily by right clicking on the database and to go Tasks -> Generate Scripts.

This will show up a dialog box which will allow you to script all or selected objects (schema, stored procedures, tables, users and views) with specific options.

TinyMCE Javascript WYSIWYG Editor in MVC3 application

This is what the output textarea looks like when you use the TinyMCE editor in MVC3 application

Text Editor

Step 1: Download the tinymce jquery version from http://www.tinymce.com/ and add the scripts to the required folder.

Step 2: Add the below scripts to the view where you want to display the word editor. Also make sure that the scripts in tiny_mce are also included to the solution.

<script type=”text/javascript” src=”@Url.Content(“~/Scripts/tinymce/jquery.tinymce.js”)”></script>

<script type=”text/javascript” src=”@Url.Content(“~/Scripts/tinymce/tiny_mce.js”)”></script>

<script type=”text/javascript”>

tinyMCE.init({

mode:“textareas”,

theme :“advanced”,

plugins :“autolink,lists,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,advlist”,

theme_advanced_buttons1 :“save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect”,

theme_advanced_buttons2 :“cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor”,

theme_advanced_buttons3 :“tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen”,

theme_advanced_buttons4 :“insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak”,

theme_advanced_toolbar_location :“top”,

theme_advanced_toolbar_align :“left”,

theme_advanced_statusbar_location :“bottom”,

theme_advanced_resizing :true,

});

</script>

Step3: Now use @Html.TextAreaFor(model => model.TextDescription, new { cols=“85”, rows=“8”}) 

in the view to display and return formatted text to the controller.

Step4: Make sure that the action has [ValidateInput(false)] attribute added to it.  Just in case, the model has <p> or other content that might be red flagged.