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...

Saturday, March 26, 2011

Go to a Code Camp!!

I went to the Orlando .NET Code Camp this year (as well as last year) and picked up quite a few tid bits of information. They put on a great event and I even walked away with a few thousand dollars in software licenses for FREE. Can't beat that deal!

If you have an event in your area, I suggest you attend and who knows what you might get out of it :)

Wednesday, March 23, 2011

Finding a Control within a RadGrid Edit Template

I’ve recently needed to incorporate a RadGrid in which my edit template contained two RadComboBoxes. Depending on the value of my first combo box, the second would be updated with different sets of data. The problem I ran into was how to connect to this second combo box so I can bind it with data.

Here’s the basic premise:

RadComboBox combo1 = (RadComboBox)sender;
GridEditFormItem editItem = (GridEditFormItem)combo1.NamingContainer;
RadComboBox combo2 = (RadComboBox)editItem.FindControl("RadComboBox2");

And the more complete code sample here:


ASPX --



<telerik:RadGrid ID="RadGrid1" runat="server">
  <MasterTableView EditMode="EditForms">
    <EditFormSettings EditFormType="Template">
      <FormTemplate>
        <telerik:RadComboBox ID="RadComboBox1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="RadComboBox1_OnSelectedIndexChanged">
          <Items>
            <telerik:RadComboBoxItem Text="Selection 1" Value="1" />
            <telerik:RadComboBoxItem Text="Selection 2" Value="2" />
          </Items>
        </telerik:RadComboBox>
        <telerik:RadComboBox ID="RadComboBox2" runat="server">
        </telerik:RadComboBox>
      </FormTemplate>
    </EditFormSettings>
  </MasterTableView>
</telerik:RadGrid>
 
 
 
 
 


Code-behind --


protected void RadComboBox1_OnSelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
{
    RadComboBox combo1 = (RadComboBox)sender;
    GridEditFormItem editItem = (GridEditFormItem)combo1.NamingContainer;
    RadComboBox combo2 = (RadComboBox)editItem.FindControl("RadComboBox2");
 
    switch(e.Value)
    {    
       case "1":
          combo2.Items.Add(new RadComboBoxItem("Test"));
          break;
       case "2":
          combo2.Items.Add(new RadComboBoxItem("Test Again"));
          break;
    }
}



Good luck :)