Wednesday, February 6, 2013

Google acquires Channel Intelligence

It's official. The company I've been working for the past 9 months has finally been acquired. By Google no less. Quite a feat for a small company. http://lnkd.in/pdNipX

Monday, February 4, 2013

Onion Architecture

If you haven't heard about the Onion Archtecture, you really should spend a few moments to check it out. If you develop code using n-tier archtectures this may just be the future...

Check out my long time friend & coworker's blog on the subject: http://www.jackpines.info/

He's got slides explaining the architecture & it's benefits over traditional layered/tiered and even has a template created to help you get started. Definitely worth the time and you may just use it for your next big project. I know I will!

Using a detailed template in a Kendo UI grid...

Just a note to myself (and this may be useful to someone else). This was using MVC3/Razor with a Kendo UI grid control. Special gotcha's in RED.


To use a detailed template in a kendo grid…

Specify the template id in the grid you are creating
@(Html.Kendo().Grid<PortalRolesModel>()
.Name("roleGrid")
   à  .ClientDetailTemplateId("roleDetailTemplate") ß
.Columns(columns =>
       {
          columns.Bound(c => c.RoleName);
          columns.Bound(c => c.UsersInRole).Width(100).HtmlAttributes(new { style = "text-align: center;" });
       })
       .Pageable()
       .Sortable()
       .DataSource(dataSource => dataSource
         .Ajax()
         .Read(read => read.Action("RoleSelect", "AccountAdministration"))
         .Model(model => model.Id(p => p.RoleName))))

Then script the template for the detailed view:

<script id="roleDetailTemplate" type="text/kendo-tmpl">
    @(Html.Kendo().Grid<SelectUserModel>()
       .Name("Roles_#=RoleName#")
       .ToolBar(toolbar=>toolbar.Create().Text("Add User To Role"))
       .Columns(columns =>
           {
               columns.Bound(ud => ud.UserName);
               columns.Bound(ud => ud.LastLoginDate).Format("{0:dd MMM yyyy hh:mm:ss tt}").Width(170);
               columns.Bound(c => c.IsOnline)
                   .Title("Online")                     
                à .ClientTemplate("\\#= IsOnline ? '&#10003;' : '' \\#") ß Must use \\# in client templates in a detailed template for this to work as just # won’t do anything.
                   .HtmlAttributes(new { style = "text-align:center;" })
                   .Width(50);
               columns.Command(commands => commands.Destroy().Text("Remove")).Width(95);
           })
       .Editable(editable => editable.Mode(GridEditMode.PopUp).DisplayDeleteConfirmation("Remove user from role?"))
       .DataSource(dataSource => dataSource
           .Ajax()
           .Read(read => read.Action("UsersInRolesHierarchyAjax", "AccountAdministration", new { roleName = "#=RoleName#" }))
           .Create(create => create.Action("AddUserToRole", "AccountAdministration", new { roleName = "#=RoleName#" }))
           .Destroy(destroy => destroy.Action("RemoveUserFromRole", "AccountAdministration", new { roleName = "#=RoleName#" }))
           .Model(model => model.Id(p => p.UserName)))
        à .ToClientTemplate()) ß IMPORTANT
</script>

Cell formatting. Reducing the size of text in a Kendo UI grid.

Here's something I ran into while using MVC3/Razor & Kendo UI by Telerik. I needed a way to minimize what was shown in the grid cells. In my case I wanted to shorten the width of a column containing email addresses. Since there aren't spaces in email addresses, word wrapping is not going to happen.

So here's how I went about it (using Kendo UI Grid (MVC Template version)):

To shorten the length of an email address displayed in a row so it will fit better I did the following (same method can be applied to shorten a paragraph or other text):

I bind my column in my grid and applied a client template.

columns.Bound(c => c.Email).ClientTemplate(string.Format("{0}...", "#= formatter(Email) #"));

I wrote a javascript function to handle the formatting:

<script type="text/javascript">
    function formatter(value) {
        return value.substring(0, 10);
    }
</script>


Yikes!

Wow.. Almost 2 years have passed since my last post. A lot has changed since then too. I'm not an avid blogger but I've sure used more than a few blogs to research issues I've come across that I couldn't quite find anywhere else. Maybe I'll continue to do so, only time will tell...