Monday, September 17, 2012

KendoUI AutoComplete and JSON for the RESTofus

Like Scott... I've oft had disdain for the web dev' experience.

Started programming in '67, and haven't missed a day since. ArpaNet was exciting, but Berner's-Lee ideas opened up a pandora's box to be land-Netscape-d, and we're still trimming the bushes.

So, I've not been all that anti-MS over the years, but they certainly have a habit of trying one's patience, don't they. The MS approach to the web is no exception: "do it this way. No, wait... that way is bad... try this."

"ActiveX, COM, DCOM, COM+, CLR, .NET, Web-sockets, not yet" it all starts to sound like a Billy Joel song. Isn't it funny how parts of 'Razor' markup resemble classic .asp? Kinda makes you long for the Scott McNealy vision all over again. Man, the transition from AWT to Swing seemed orderly by comparison.

So... way back in the dark ages of 2002 ASP.NET with ViewState seemed like a good idea. Yeah... that was the ticket. We can think like desktop-developers, not worry so much about state-preservation, and concentrate on the LOB app's biz-rules. Nice. Until ViewState became larger than the page, and every thing that a poor user did caused churn and grunts as latency destroyed patience and the number of postbacks caused epileptic fits.

So we used lots of server-side widgets (gotta love those grids) to help. Things got slightly better... but, there was no way that I could not shudder at the thought of the poor users sitting in the office, forced to enter data into a system that was 2-4x slower than it should be. And.. after trimming Session and ViewState, and using more JS to reduce round-trips, we still ended up with users hating the experience, going into epileptic shock from the latency blues. Remember the promise of 'SmartNavigation'? Never worked well, right?

So, we all started to take a hard look at AJAX. Loading data asynch'ly client-side... wicked pissah. Telerik had some fantastic examples and widgets embracing the paradigm. For me, the JS door cracked open a little more; getelementByID and InnerHTML became good friends.

And then John Resig did us all a huge deed. jQuery saved the day. All of a sudden, JS was almost a real language. And... we started to escape from the bondage of the mighty MS 'long and winding' road-map.

OK... I've been typing too long, and I really wanted to talk about my latest KendoUI experiments.

So, have YOU tried to get the KendoUI AutoComplete to do its thing for you? Do YOU have it working with a RESTful JSON remote datasource? Well... I must say, it was more than a bit of pain, and it wasn't exactly a 'restful' project dalliance. but... maan.. it rocks.

Feast your eyes on this and behold the beauty:

$("#patSearch").kendoAutoComplete({
minLength: 2,
placeholder: "(Initials, DOB, MRN)",
suggest: true,
animation: { open:
{ effects: "fadeIn",
duration: 300,
show: true
}
},
dataTextField: "LastName",
dataSource: this.patients,
template:
"<span class='patSearchRow'> ${data.LastName.trim()},${data.FirstName}-${data.DOBString}-&nbspMRN:${data.MRN}-${data.ID}</span>",
select: function (e) {
if (e.item !== null) {
var theitem = this.dataItem(e.item.index());
session.setPatientInContext(theitem);
}
}
})
autoComplete = $("#patSearch").data("kendoAutoComplete");
autoComplete.list.width(400);
autoComplete.list.addClass("patSearchRow")


I'm starting to like Kendo, and love it's harmony with (and the ubiquity of) jQuery. It's not just that KendoUI rocks... it's the attitude of the whole JS-library community. There's alot of great people putting tons of effort into JS. And soooo many cool things we can now do for our enslaved users.

It's not exactly easy yet... but we're getting there.

More later... the bees are a-callin'. Time to put more sugar-water on the hive; winter's coming.

Long live ECMAscript !

Wednesday, September 12, 2012

KendoUI's AutoComplete and JSON for the RESTofus

so.. yeah, like Scott... I've oft had disdain for the web dev' experience.

Having worked in just about every stateful environment there is over the years, it was both joyful and painful when ArpaNet was finally blessed and the web became something more than a Berners-Lee rolling paper.

Heck, even 68000asm had better support for real programmers when it was born.  So, back in... somewhere around the early daze of Win95.. when the suits realized that color monitors were good, CDs werent the devil and 3.5"diskettes were... we all had to look at how we too could play.

Active Server Pages bit like the .asp they were.   Javascript?  ok.. that was something that the Netscapers cooked up so we could finally validate some data that we had started to collect... we could now actually build a community by allowing peeps to sign-up themselves... actually typing in their own email to OUR webpage... and we could even store it in a database.  Whoopee.  Playing with Alert() and window.open was fun.  How much time can you spend preventing submarining?  oh the joy.

But... run... a REAL biz-app... in a browser?   Riiiiighhhht.   Point-of-presence sites were fine for me, but sh-t, maan... do you really want to trust your biz-data to an HTML app?   CFML was a godsend, and Jeremy Allaire my personal hero.  That helped a whole bunch.  <CFQUERY> was a big deal.

Roll it forward.

ASP.NET with ViewState seemed like a good idea.  Yeah... that was the ticket.   We can think like desktop-developers, not worry so much about state-preservation, and concentrate on the LOB app's biz-rules.  Nice.  Until ViewState became larger than the page, and every thing that a poor user did caused churn and grunts as latency destroyed patience.

So we used lots of server-side widgets (gotta love those grids) to help.  Things got slightly better... but, there was no way that I could not shudder at the thought of the poor users sitting in the office forced to enter data into a system that was 2-4x slower than it should be.  

Other projects forced a hard look at AJAX.  Loading data asynch'ly client-side... wicked pissah.  The JS door cracked open a little more; getelementByID became a good friend. InnerHTML was for me.

And then John Resig did us all a huge deed.  jQuery saved the day.  All of a sudden, JS was almost a real language.

OK... I've been rapping for hours it seems, and I really want to talk about KendoUI.  Here we go.   Have YOU tried to get the KendoUI AutoComplete to do its thing for you?   Do YOU have it working with a RESTful JSON remote datasource?   Well... I must say, it was more than a bit of pain, and it wasnt exactly a restful project dalliance.  but... maan.. it rocks.   Come to the MeetUp... and we'll show ya.

More later... the bees are callin.  Time for more sugar water.