I’ve blogged before about the enabling features of Monorail and Active Record, part of the Castle stack. Another piece of software which is making my development life a pleasure is ExtJS - a collection of javascript goodies created by Jack Slocum and his team - and when these three things come together, watch that coding fly…. I’ve created a screencast in which I demonstrate how easy it is to build a paging, sorting, filtering, AJAX-powered grid using ExtJS and Castle, and you can watch it here. It’s 20 minutes long but filled with goodness - and a couple of hacks (forgive me :). Don’t forget to check out all my past screencasts too.
UPDATE: As requested in the comments, you can MonorailExt1 VS Project directory of this.
great introduction colin! I need to get up to speed on the ActiveRecord stuff.
i laughed when you started doing the sorting and you said, “ohh, thats brilliant!”
rofl
Sean Chambershaha, everytime I play with ExtJS I come out with new superlatives!
Colin RamsayColin,
So, have you tried teh JSONHelper stuff with an ActiveRecord model that has relationships? I get a “Self referencing loop” error, and can’t find much with a google on how to get around it.
The screencast was great. Thanks, mate.
RuprictRupert, there’s a property that you can configure to define the behaviour when dealing with self-referencing loops, look at Newtonsoft.Json.ReferenceLoopHandling. Failing that, look at the property that is triggering the error and add the JsonIgnore attribute and that will solve it.
Colin RamsayLooks great.
I’m curious about Castle, but thought LINQ would negate the need for Castle. Can you explain?
Have you tried using LINQ with extjs?
And finally, how would this work for data that requires athentication?
thanks!
DonalLINQ is Language Integrated Query and is basically a querying syntax using new keywords. You could use LINQ to SQL to replace the ActiveRecord portion of my sample, and probably C# 3.0’s new anonymous types to help with the JSON (a bit):
http://colinramsay.co.uk/2007/05/08/working-with-json-and-c-30/
But neither of these are replacements for Castle. Working with LINQ for SQL and ExtJS should be pretty simple, it’s just another means of querying the DB.
If you want authentication, well the monorail actions which are building the JSON have full access to the session and cookie data so you could use an MR filter to exclude access to unauthenticated users, or something like the PrincipalPermission attribute. More info on both here:
http://www.castleproject.org/monorail/documentation/trunk/usersguide/authentication.html
That’s a pretty common usecase in Monorail and is straightforward to implement.
Colin RamsayCould you post the source code for this screencast?
JayLooks great, I’ve got to get looking into the ActiveRecord stuff.
Tim MatherNice screencast, while i was researching a little for ExtJs i found out ExtSharp, how you tried this? it really looks better than handwritting all that JS.
http://code.google.com/p/extsharp/
Anyone tried this and can give any feedback???
RLRL:
I’ve tried ExtSharp, and I’m not keen. I had to uninstall it as it broke my visual studio (I can’t remember exactly what happened), but even when I had it I saw it as nothing more than a curiosity.
I really like JS, and I see little value in providing a layer on to of it which does nothing other than translating to it.
If you want to use *ExtJS* then you need to get into the guts of javascript to understand and use it correctly, otherwise you’re going to hit problems.
When you say it looks better than handwriting the JS, well, you’re still going to be handwriting the C#, but as a web developer you should be fully versed in javascript and comfortable with writing, debugging and understanding it.
The main draw for ExtSharp for me was the intellisense and suchlike, which would be great. Potentially Aptana could do this for the JS, but I’ve not seen it working.
Colin Ramsaygreat screencast.
i think you have a bug at the end of it, though.
for your character-filtered dataset, when you add “totalRecords = accounts.Length;” (at around 21:00) that would still only return a max of 8, right? so you should really run another query with only the ‘like’ criteria, not the sort, start or limit.
nate batesnate:
Yeah, looks like you’re right. That’s what I get for not planning better. I do actually catch a similar thing in the unfiltered case (when I do totalRecords = Account.FindAll().Length) so I’m not sure why I didn’t see it when filtering.
Colin RamsayColin: I know you have to understand JS, that was never in cause, however the thing a find interesting is to be able to write in on C# and have those fantastics things like (Code completition, refactoring and compilation errors :-] ) that _should_ save you some time and avoid stupid errors that make you spen time. Besides that is totaly useless.
RL[...] ExtJS (a grid) [...]
Screencast goodness « How to become a better developerYou should take a look at this post from Jack. I am using the Spket editor with Aptana and the help is good.
http://extjs.com/blog/2008/02/01/ides-plugins-and-tools-for-ext-js-20/
BirenHi I am new to Extjs framework. I am a C# .net programmer. How can i bind data to extjs grids and update and save etc
that data back to my database??
Please if you can show me some vedios or help me
SunshineThanks in Advance
Can you please post the source code. the link does not seem to be working.
Thanks!
Kevin