Monthly Archives

April 2014

LINQ Aggregate Operator: You Don’t Need It Until You Need It!

By | .NET | No Comments

Lately I write so many LINQ queries on an almost daily basis that it is easy to think I have used every kind of operator in one way or another. It’s kind of fun, really – trying to come up with the most efficient query to get what I want out of a collection of items, for example.  But even when I have been using it for a while, LINQ can still surprise me! I have used the other aggregation operators repeatedly, and they are perfect for my typical aggregation needs:  sum, count, average, min, and max.  But this Aggregate…

Read More

Hello, who is this? Controlling the context of a MVVM click handler

By | News | No Comments

This time I wanted to share something that might be a bit esoteric about Kendo MVVM bound click event handlers, but I think it’s kind of interesting and I hope you will too. Consider the following markup and code:

What do you think the outcome will be when you click each button? Kendo MVVM click handler context Were you surprised? The button bound to viewModel.inner executed inner.buttonClick but this.get(‘clickOutput’) returned the clickOutput defined in viewModel, not viewModel.inner. Now, obviously the code sample here is highly contrived, but I like to use nested objects in real projects to organize…

Read More

Geolocation Tracking in Kendo UI Mobile and Google Maps

By | Kendo UI | One Comment

There are many posts out there about getting the current geolocation of a user via HTML5. However, in this post, I would like to show you how you can track a user’s geolocation. After all, what good is getting the current location of a user if they are mobile and on the move?? So here we go… Geolocation API The geolocation API is exposed in JavaScript using the navigator object. It is supported on all mobile devices running HTML5 browsers, which is almost all of them now. This means you can comfortably use it and even have a fallback if needed:…

Read More

Restricting Drag & Drop Levels for Kendo UI TreeView

By | JavaScript | 4 Comments

Drag and drop for the Kendo UI TreeView works so well straight out of the box that you may use it for a while without ever needing customization.  And even when you do, the TreeView events make it simple to manipulate the operations.  Take for example a situation where the user should be allowed to drag and drop, but not to alter the original level (parent or child) of the items themselves. All we need is some property on the DataSource items that can tell us if an item is a Parent, and then do some simple validation within the…

Read More

Preventing default action for an element in AngularJS

By | Web | One Comment

Assume you have an anchor button and you want to prevent default action of the anchor tag in a app using AngularJS. The code below shows you how – HTML <a class=”button” href=”#” id=”setFilterButton” ng-click=”setFilters($event)”>Set Filter</a> HTML above is pretty straight forward and something you will find with any ng-click with one exception. We are now passing $event to ng-click. We will make use of $event in our controller to prevent the default action. Javascript $scope.setFilters = function (event) { event.preventDefault(); console.log(‘Clicked!’); }; So in the controllers setFilter method we accept the event parameter passed from HTML and just call…

Read More

Sharing Resource Dictionaries in your Universal XAML Apps

By | Uncategorized | One Comment

My colleague Josh Morales has already touched on the new Universal XAML Apps, but I wanted to touch on one of my favorite new features. One of the big selling points to developing native Windows applications is that you can share a significant amount of code between Windows 8/8.1 and Windows Phone applications. Now with the new Hub App project type in VS2013 Update 2 RC, the ability to share code between Windows and Windows Phone has taken a huge leap.   Portable libraries are extremely useful for sharing base classes but have had limited namespaces in the past. Hub…

Read More

Angular Part 5–Adding A Service

By | Uncategorized | No Comments

This is the fifth in a series that starts here. In the previous installment, we looked at using Jasmine to test a Controller, and left off with the suggestion that our program would be improved by adding a service.  We’ll add that today. Before we get to adding a service, however, it is time to make our application a bit more realistic by adding a couple views.  We’ll do that by adding an Admin and an Expense folder to our App folder. The former will hold views (html) and code (JavaScript) related to administering the application, while the latter will…

Read More

Explicit Wait. It Doesn’t Mean What You Think It Means.

By | Uncategorized | No Comments

When Is Explicit Not Explicit? Because confusion about terminology has never happened in the software industry ever, anywhere… When you hear the term "explicit wait" do you think of something that looks like this: Thread.Sleep(some_explicit_time_period); or do you think of something like this: wait.Until(some_explicit_condition_is_met); The general intent of both statements is the same: wait long enough to deal with a specific timing situation in your system. The fundamental concept of the two statements couldn’t be more dramatic in their implementation–and those differences have considerable impacts on how your test automation suites will work over time. Why Wait At All? In…

Read More

Dirty Children and Kendo UI

By | JavaScript, Kendo UI, MVVM | One Comment

One of the great things about MVVM is the ability to make a change to the underlying ViewModel and the change “automagically” appears in the View.  Kendo UI takes this one step further by allowing you to define a Model (either with or without a DataSource) and all changes will be tracked.  This allows you to either cancel those changes and revert your data to the original state, or automatically detect whether changes have occurred and save those back to your service. This works flawlessly in Kendo, except in one scenario I’ve found.  If you have a hierarchy of objects…

Read More

Live in Dubai: Sitefinity Workshop for Developers

By | Uncategorized | No Comments

Learn more about the instructor, Lino Tadros, CEO of Falafel Software and Certified Sitefinity Developer. Lino Tadros CEO, Founder Falafel Software Inc. Don’t waste a second! Be productive with Sitefinity Content Management System in this exclusive, full day, on-site training class. Get full control over your website using the Sitefinity API and the powerful Sitefinity Fluent API. You’ll learn in detail how to manipulate all the CMS manager objects in the system, from querying website information to creating, updating and deleting content. Learn how to develop templates, custom widgets and custom modules. You’ll also learn script debugging, AJAX tips &…

Read More

Xamarin and Telerik Talk: Lino Tadros Speaks at Microsoft Gulf Next Week!

By | Uncategorized | No Comments

Registration is filling up, sign up today! When: April 29th, 2014 6:00 – 9:00 PM  Where: GEMS Room Microsoft Gulf, Building No. 8, Dubai Internet City Dubai, United Arab Emirates  Cost: Free! Register Now! Expert developer and Falafel CEO Lino Tadros will be speaking at Microsoft Gulf in Dubai Internet City on April 29th. Don’t miss an exclusive opportunity to see Lino Tadros speak on building iOS & Android Apps with C# using Xamarin, and an introduction to using the new Telerik Platform to build, test, and publish Mobile Apps. Intro to iOS & Android Apps with C# using Xamarin In this session Lino Tadros…

Read More

Angular Part 4–Testing AngularJS

By | Uncategorized | No Comments

This is the fourth in a series that starts here.  It is time now to turn our attention to testing AngularJS applications.  Over time, we’ll want to move to test-first, where we write the test and then write the code. There are many advantages to test-first, but let’s hold off on discussing them until we’re ready for that step. Today, I’d like to discuss testing Controllers.  Controllers were introduced in the previous posting.  To make sure we’re all on the same page, let’s start with a common starting project, which you can download here.  This stripped down project has no…

Read More

Dude, Where’s My Data? Kendo, DataSources, Wrapping, and You.

By | News | 3 Comments

When working with Kendo DataSources, it is very easy to accidentally disconnect your original data from the data in the DataSource. Understanding the causes will let you prevent this from happening and keep all references to your data pointing to the same place. Observable Wrapping Example 1

This example illustrates a classic case of disconnected data. After binding the grid to the data variable, changes to the data variable are not reflected in the grid. The reason for this is that DataSources wrap their data in an ObservableArray of ObservableObjects. These two classes allow bindings to be aware of…

Read More

Include CSS and JavaScript Resources in Sitefinity MVC Widgets

By | Sitefinity | 3 Comments

When Sitefinity added MVC in version 5.1, it was a real pleasure to create widgets the “new way” via MVC. What made it so unique is that Web Forms was still offered in the platform for developers to use as an alternative or hybrid approach, so you can mix Web Form and MVC controls on the same page. After the honeymoon stage was over, the community started to realize there was some serious limitations to the MVC implementation that made it nearly impossible to create pure MVC pages in the real world. Some examples were not being able to use your own…

Read More

Early access to Windows Phone 8.1 for Windows Phone Developers – NOW!

By | Uncategorized | No Comments

Updated 04/14/2014: If you’re a Windows Phone developer, then you are now able to update your Windows Phone to a developer preview of Windows 8.1, including Cortana. All you need to do is install the Preview for Developers app and then check for updates on your phone. As soon as I get the new bits installed, first on my list of new API’s to try out is the Nokia SensorCore bits. Very exciting times for us Windows Phone developers.

Read More

Lookup Columns in Kendo Grid

By | Kendo UI | One Comment

There’s a number of forum posts wanting to use a lookup table for a column in a Kendo grid, where the lookup has text and a numeric id, and where all of the operations like grouping, sorting and editing need to behave as expected. The trick is to provide the lookup without causing problems for sorting, filtering, grouping or editing at the same time. Many of the online examples use a drop down list to lookup into a list, where both the text and value for the drop down list use the text data. Real-world scenarios use a foreign key…

Read More

Angular Part 3–BDD With AngularJS

By | Uncategorized | One Comment

In a previous posting I introduced the critically important topic of Behavior Driven Testing, but the example I gave was straight JavaScript rather than Angular. We’ll want to modify that example to be Angular, but to do so we need a bit more of the fundamentals under our belt. Let’s return to the previous program and modify Index.html, which will be our opening page.  Make sure you have a link to Bootstrap.css as shown below.    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" ng-app="app"> <head> <title>Expenses</title> <link href="Content/bootstrap.css" rel="stylesheet" /> </head>   One key feature in this listing is the presence of the…

Read More

Extending Sitefinity RadEditor to add a custom blog manager dialog

By | Uncategorized | 2 Comments

Telerik’s RadEditor provides a wealth of functionalities to manage a wide range of content including Videos, Images, documents, Hyper Links and text manipulation.  One of the key features of the RadEditor is the ability to extend these built-in functionalities and add easily new dialogs to provide new functionalities using both its client-side and server-side APIs. One of the cool feature that is missing is the ability to Link to blog posts directly from the editor without the need to leave the page and check for a particular post that you want to reference while you are creating/editing content. In order…

Read More

Aggregates with Kendo DataSource

By | Kendo UI | 2 Comments

A small point of concern with Kendo UI aggregates is simply the naming conventions. While the Kendo UI DataSource can calculate min, max, sum, count, and average aggregates for any column and output these aggregates at the group level or for all of your data, there is more than one way to get at these calculations. There are configuration options aggregates and aggregate, properties within those options called aggregate, and just for extra fun, methods called aggregate() and aggregates().

Let’s try to sort these out

Read More

Custom Editors with Kendo Grid

By | Kendo UI, Web | One Comment

The Kendo UI Grid makes it easy to display and edit your data in a tabular format.  By default, the grid will use a TextBox for string and numeric data columns and a DropDownList for editing columns with a list of options.  What if you want to use a different editor type?  I’ll demonstrate two examples of using a custom editor for a grid column: MultiSelect and NumericTextBox. Custom MultiSelect Editor There are a few steps to use a MultiSelect as a column editor.  The first is to make sure your data is formatted correctly.  Looking at this sample DataSource,…

Read More

First Look at Windows and Windows Phone 8.1 Universal Apps with Visual Studio 2013 Update 2 RC

By | Windows | No Comments

Although I didn’t have the honor of attending Build this year (someday!!), I thought I’d do the next best thing and grab the latest bits and get my feet wet with the new Universal apps for Windows and Windows Phone, available with the newly released Visual Studio Update 2 RC. The installer ran without a hitch, and after a quick reboot I was up and running, though as far as I can tell nothing significant in the UI has changed. I was worried I would first need to install the Windows 8.1 Update as well, but apparently this is either…

Read More

Angular Part 2– Behavior Driven Development

By | Uncategorized | No Comments

In an earlier posting I discussed, briefly, why Angular is suddenly so popular, and demonstrated how to get started with Angular without writing a line of JavaScript.  It’s time now to turn our attention to a slightly more realistic example. Many lessons on Angular pay lip-service to the importance of unit-testing and test-driven development, but virtually none actually practice it.  This series will buck that trend and teach Angular and testing Angular at the same time.  In the long run, this will be faster and better than trying to tack testing on at the end. Test Driven and Behavior Driven…

Read More

Kendo Tip: Accessing Widget Instances

By | Uncategorized | No Comments

When a KendoUI widget is created the widget instance is attached directly to its associated DOM element using jQuery’s data method. This allows developers to easily interact with the widget in other parts of their JavaScript code. To grab the widget instance simply use jQuery to select the element with which it was instantiated and call the data method, passing in the name of the widget as the key. $(‘#my-grid’).data(‘kendoGrid’); It should be noted that if the jQuery selector returns more than one element, only the Kendo widget associated with the first element will be returned, if one exists. This…

Read More