23
Sexy DataTables with for Asp.Net MVC
Just thought I’d pass this little gem on as it’s saved me a lot of time (eventually) and given me a much more finished solution in the end than my hacked together attempt. Whilst trying to produce a simple reporting app I required a table view along with pagination, sorting and search, I went about trying to produce each individual element in MVC and had come up with a half-baked solution but it didn’t “smell right”. Anyway whilst surfing t’interweb I came across this tutorial
It was a really simple way to create the exact table I wanted with out using Grids etc.. The only issue I had came from using MVCContrib the version I used needed MVC 2 so I upgraded the project by starting a fresh and cutting out a load of controllers and views etc. All in all a much more finished attempt thanks to the great work of Allan Jardine and the MVCContrib guys.
Resources:
20
A D’oh Moment
I know this is something that most devs will not find interesting but it really made me smile when I stumbeld across using static members to count object instances. Like I’ve said I’m a noob and have jumped between technolgies so I decided this week to focus on learning the C# 3.5 Language from the ground up. I dug out my copy of Step by Step C# 2008 and decided to do a Chapter every time I needed a 5 min break from my Drudge (Smokers can have a Cigarette, why can’t coders have Dev Breaks??). After running though the variables, DataTypes etc I came across the classes and methods sections then got to the statics Which had the following little sample which I found very enlightening and though I’d share. It will also be for personal ref later.
using System;
namespace TheBasics
{
public class Circle
{
private int _radius;
public static int numCircles = 0;
public Circle()
{
_radius = 0;
numCircles++;
}
public Circle(int initialRadius)
{
_radius = initialRadius;
numCircles++;
}
public double Area()
{
return Math.PI*_radius*_radius;
}
}
}
So basically what this would allow you to do is Call the Static value numCircles which would have a count of all instances of the Circle Class. Simple I know bu t I liked it
Circle circle1 = new Circle();
Circle circle2 = new Circle();
Console.WriteLine("There are {0}, Circle objects",Circle.numCircles);
On A side note whilst creating This post I was struggeling to put nicley coloured and formatted code into the post. I found this and It worked a treat
Digital Infamy
Twitter Updates follower me here
- Just caught @cathallison hoovering the toaster. brilliant lmfao
- Watching secret millionare with a lump in my throat. Need to go to bed but want to see the end. Little girl is amazing carer
- RT @martinfowler: An survey of ThoughtWorker opinion of Version Control tools: http://martinfowler.com/bliki/VcsSurvey.html



