Keith Chadwick
doILookFunnyToYou@hotmail.com (I.M.)

Updates and Ramblings

Stalled in a Petrie Dish
April 16th, 2007 - 10:30 AM

I though time for an update as it has been over a week since I last provided any information and I am getting inquiries from various sources.

The new column resize behavior to move only the headers and resize bar has been completed. This replicates the behavior of the existing data grid.

The rendering of the data is now down using a pseudo page mechanism which provides for much quicker rendering regardless of the size of the underlying dataset. There is a couple of small quirks in it that need to be addressed but they are fairly simple.

At the moment though three factors have stalled development at the moment. The first is the learning curve for integrating the component into Javeline itself. Not an overly difficult taks just one of those learning curves you are faced with now and then in our world. The hard part is just getting your brain into learn mode again. The second factor is regular work has ramped up as I have an event registration to develop this week, SarScene2007. Not a big deal but it can be time consuming. The third and final factor is that my two little children who act like petrie dishes for germs have lovingly brought the whole family down with a nasty head cold. So I type this sniffling with head pounding trying to get my brain in gear to do some more testing on Javelien integration. We will see how it goes today ;-)

Reboot
April 6th, 2007 - 10:00 AM

Well its has been a week of work distraction resulting in not having any chance to work on the datagrid. As it is now Easter and the clients are all busy eating chocolate I can have a some time to get back to the control.

I must admit that the break from the control was a good thing as it allowed me to think about the current state of AJAX in our world. Don't worry this is not another brain dump. As an independent developer I try to have as many sources of inspiration as possible. Thus I have one foot in Javeline and another in Dojo. Each of these frameworks have there own advantages but I honestly must say that I think both have been eating to much chocolate. This is not necessarily a bad thing but often I think the AJAX Frameworks dumb down the user by trying to do everything for you.

As a result I am starting to wonder if there is a need out there for a AJAX Light Framework. The mission statement of such a framework is to provide cross browser data get and put for XML and JSON, event binding, browser sniffing and some basic form controls. Perhaps this is a project I could take on later by taking the best of different frameworks, who knows.

Now onto more immediate things. Had a chat with Ruben this morning, he types more relaxed so I think the holiday did him some good. He indicated that there was a far wedge of people out there following my progress. That was nice to hear, they must be the silent types. So back to the datagrid!!! We are going to add in a property to change the column resize behavior to replicate the old grid. This means that only the resize bars will move until the mouseup behavior then the rest of the columns will resize. The property will sit at the datagrid level and I shall call it resizeBarsOnly.

Moving on to Data Integration
March 30th, 2007 - 10:00 AM
Well its been a tough couple of days and yesterday was a bust as far as work goes but thats the way things go some times. The SizeServer and HeadServer have now been completed as far as I can go without doing the databinding component.

Starting today I will be working on the databinding component. This will use Javelines' native data collections as XML is XML. When that has been completed I can go back to the Filtering behavior supplied through the column header menu of the control.

Once that is done the two last steps are 1) Integration with Javeline Skins and 2) Delaing with corosive CSS. What do I mean by corosive CSS, well if the developer decides to start adding padding and borders and make the interface ugly I have to deal with how these impact on the measurement and placement of objects. I thought of this from the very beginning so I only need to deal with it in 3 specific areas. In the datagrid base the __gridSize function and in the column class the __size and __position functions.

Time for some Optimization
March 27th, 2007 - 7:26 PM
There comes a time in the life cycle of both an application and object where you have to take a step back and do a little review of what you have written. This is the time for the dreaded printout, yes actual paper! At the moment all of the code, all 1006 lines including comments, is contained within the actual datagrid control. Obviously there is some that could be ported over to some common objects/functions. In the case of the existing Javeline datagrid control a prime example of this is the DgSizeServer. This "server" manages the resize of the columns. The purpose of this is to reduce the footprint of the actual control.
Column Smart Resize
March 27th, 2007 - 9:00 AM
I have noticed an annoying behavior in the column resize. Once the column becomes sticky as you start to shrink the column to the left the columns on the right remain sticky until they hit there max width. To me this is annoying as I want it to go back to its original width before it got squished and sticky. In order to provide for this I have added a property to the grid control called smartShrink(boolean).

The property when set to true will set the columns back to there original size only then become unstuck. As an example we have columns a, b, c and each column is 100px wide with a max of 300 and a min of 50 and the grid is 400 wide. When column A is expanded to 300 columns B and C become 50 wide and are stuck. When you shrink column A down to 50 columns B and C would become unstuck when they reached a width of 100. If smartShrink was set to false columns B and C would be 175 each and still be stuck.

Window Resize Behavior
March 26th, 2007 - 11:00 AM
We have a real problem with regards to resizing the grid control automatically when the parent object/viewport/window is resized. The problem is in regards to Firefox and Safari. Both of these browsers support the ONRESIZE event but only on the window object and not on an individual element. Internet Explorer on the other hand provides the event on an individual element.

Again we are forced to make a decision on a control behavior. All things being equal the best possible solution is to have the object recalculate its column widths when it is resized. There are two types of resize that can occur. The first is when the window is resized and the second is when the grid container object is resized. The latter of course could be triggered by the window resize event itself.

For consistency of behavior the resize event will be bound to the window object and not the control. The main problem with this is if the container object is resized via code. In order to be able to catch this I will provide a public method on the grid entitled .recalcSize().

Firebug guided me out of the Jungle
March 26th, 2007 - 10:00 AM
Well column resize has finally been completed along with the sticky column issue. It was a real nightmare to debug and it it was not for Firebug I think I would have given up in despair and anquish. For those of you not familiar with Firebug, it is a free add-on for Firefox that amoung many things, allows you to step through your javascript code. This tool is indespensable for doing "high end" complex javascript implementations such as we have in the AJAX world. The fact that it is free is amazing, I would gladly pay a couple of hundred bucks for it.
The Garden Path has led me to a Jungle
March 22nd, 2007 - 9:50 PM
I think I am going to loose my mind very soon if not already. Everything is working well on Sticky columns except if you move the mouse to quickly. At first I thought this was due to the onmousemove event being kind of chunky when it dispatches or that the event cue was filling up due to the time it takes to calculate the subsequent columns.

In order to test this theory I created a one line event that simply sets the current X on a global var. The actual resize funtion is called on a timer that first tests to see if the previous X is different from the current X. If they are the same it exits. Fairly routine and amounts to two lines of code so how much more effecient could it be.

Alas the same blasted problem still exists. If you move the mouse to quickly it misinterprets the far right border and starts to shrink the columns before they are sticky. It even reports that they are sticky yet they are not.

I am not sure if the existing datagrid has the same problem. The test that was provided to me by Ruben already has the columns stuck on rendering so this is not an issue. Tomorrow I shall modify the example and rip through there code to see how there solution was done. I have already spent some time reviewing there DGServer code and as far as I could tell not much different than what I am doing.

I think it is perhaps time for a brain break on this problem. Perhaps a game of Age of Empires to clense the cranium is called for.

Laundry and the Garden Path to Sticky Columns
March 20th, 2007 - 11 PM
I spent the better part of todays daylight hours completing some long over due laundry tasks while I let my brain wander on column resize behavior. You might think a whole day is a lot of time to do laundry but when you have a 6 month old and a 2 year old, laundry is a never ending repetitive sequence. As I folded and argued with the wife over clothe organization, a contentious issue of hang or fold, my mind kept comming back to sticky columns.

First lets get a few things clear. Design decisions made as a result of past decisions that result in the convulating of something simple into something overly complex simply demonstrates poor planning, or does it? It is often the case, despite the best laid plans, that interface behaviors lend themselves to further behaviors that only become apparent once the initial behaviors are in your face. This is called being led down the garden path and often results in us, we developers, writing some realy cool shit that nobody realy gives a dam about, specially an end user. But hey, its realy cool though right and thats good enough for us, right? Well in a utopion world sure why the hell not but lets take a step back to reality and food on the table and talk about STICKY columns.

Your basic datagrid has a bunch of columns that you can resize. I resize a column larger and the ones to the right move to the right as a result, if I shrink a column the behavior is obviously the opposite. When the columns exceed the width of the containing window-object-viewport you get a horizontal scroll bar, very simple and obvious. You should be asking yourself right now why is that so obvious. Well the answer is that because that is how the windows explorer works or the Mac Finder works. The next question in your head should be but why does it work that way? The answer is because its simple and most people can understand it and more importantly it is now institutionalized in the computer vernacular! So STICKY columns, where getting there.

On the web people are used to things being dynamic, when they resize there window the contents resize with it. This is all fine and dandy but as many of you know it can also be a real pain in the behind. Since this is an expectant behavior in a web gui lets introduce columns with widths as percentages. From a presentation point of view the behavior of the grid is still the same. If the sum of the percentages is greater than 100 then the column(s) that exceed the 100% do not appear in the grid and a horizontal scroll bar appears. Again what is STICKY?

Now lets introduce 2 behavior delimiters to our grid columns. These are min-width and max-width. The behavior mods obviously limit the size of the column width and also obviously, you should be able to set them as either as percents or fixed pixel. So does our grid behavior now change, yes, but only slightly. If the parent object is resized the columns again resize themselves but if in doing so can only go up to its max width and vice versa when resizing the parent object smaller. When the user resizes a colum larger or smaller the same rules hold true. Resizing is stopped when either the min or max is reached. Almost to Sticky!

Lets introduce one final datagrid property. Lets call it NoHorizontalScroll, NHS for short. As you might expect when this behavior mod is turned on it prevents the grid from showing a horizontal scroll bar. This means as the user resizes a column, columns to the right could end up disappearing and be unaccessible. Now from a gui perspective NHS results in a completely unacceptable interface behavior, content disappears!!! This would freak your average user and they would start hitting the refresh button like mad and sending you weird support emails with lines like 'my data has been deleted' or 'do I need a bigger monitor?'. Sounds silly but we have all heard the stories of user stupidity and some of us have even been in them. Again what about Sticky?

Now we have a problem, we obviosly can not allow columns to be hidden and become innaccesible. So our solution is we have to prevent the user from resizing a column to large that it results in forcing other columns of the grid. But what if the grids' width is already at 100% with columns. Well, thats where min-width comes in. If the user resizes a column larger, the columns to the right are pushed to the right until the last column reaches the far right of the grid container. Then as the column continues to be enlarged the subsequent columns are decreased in width until they reach ther min-width. Once all the columns have reached there min-width the column being enlarged can no longer be made any larger. A little more complex of a behavior for sure but again this seems to make complete sense. But what about when the user resizes the column smaller? If they have resized there column as wide as it can go then make it smaller do the columns to right simply move to the left. Remember now that those columns are at there min-widths so there content might be unreadable. Again from a gui perspective this would seem a bit obtuse and ugly so obviously we have to do something a little better and smatter.

At last sticky columns!! Given our previous scenario what we need to have happen is the columns to the right need to automatically make themselves larger as more space is made available when the user shrinks the original column. This means that the far right column remains STUCK to the right hand edge of the datagrid, hence Sticky Columns! It remains stuck until such time as its max width has been reached and then it begins to move to the left but only when all other columns between it and the column being shrunk have reached there max-widths. For the last time from a gui perspective this would be ther expected behavior.

Now, if you have read up to this point you are most likely saying to yourself that yes the above makes complete sense. If this is so then I have some boots for you because you are firmly on the garden path!

"To Stick or Not to Stick, that is the question?" Lets remember that a datagrid is a grid with a bunch of columns that you can resize and when they are to big a horizontal scroll bar appears and that is it!! How far have we strayed from this tried and true lexicon of gui? Is there such an apparent reason to? Why havn't the O.S. developers with there bags of money and industrial phsycologists made this astounding leap in gui logic? The most basic and simple answer is because its overkill. It makes something simple and apparent work in a way that is conterintuitive to your average user.

All you young developers out there seem to think that this is all so obvious but a majority of users can't find a web page link unless its blue and underlined. I did a nice little web page for a client where the links where a dark blue with no underline but changed color on mouseover and he got complaints from people because they did not no where to click. I kid you not!!! Interfaces have to be obvious and improve the quality, quantity and accuracy of the targetted audience. If you are designing something to go to market keep it simple. Chances are if its obvious to you its not obvious to your users. Interface is the most important aspect of any system. I know dba's will argue its the database, .NET, ASP, PHP, CGI folks will argue its the middle tier because thats the business layer but they all count for nothing if your interfaces suck. You know why? Because know one is going to use your terrible gui to that incredible business middle tier and 5th modal form database!

The above brain dump is the result of to much time thinking while doing laundry. Now I am off to finish my sticky column code because ITS REALY COOL!!!

March 20th, 2007 - 4 AM
Well its late but after a nice bottle of Merlot and far to many cigarettes I am close to resolving the column resize issue when the grid has noHorizontalScroll set to true. Its a real brain task in debuggin but overall is actually only about 20 lines. The column resize issue is probably the most difficult task to code for. After this it should be smooth sailing for data and skin integration plus the bells and whistles I want to put in. Think I am going to hit the sheets now as I believe I am on deck to get up and feed the baby at 6AM. I think this classifies as a ramble :-)
March 19th, 2007
Completed the data loading feedback interface. Tried to be a bit smart with the grid dataloading. Only the initial page of data is created on load in order to reduce render time. As the user scrolls down the necessary cells are created. If the user pages down or scrolls to the bottom they get a percentage loading feedback in the middle of the grid. I ran some volume tests on the control with 2000 records displaying between 1 and 5 columns and it performed fairly well.

Completed the min/max width functionality plus the column resizing on document resize.

March 16th, 2007
It has been a couple of days since I have been able to do any work on the datagrid control and it has been longer since I have updated these pages. Given this I thought it prudent to start a bit of a blog on the current progress.

Before Ruben left on holidays in warmer climates we had the chance to have some discussions of the column auto sizing features. It came down to two choices, either support mixed column formats, i.e. % and PX, and bind the the body.onresize event or do not allow mixed formats and do not bind to the body.onresize event. The reason this has to be discussed is that if you start to bind your control to DOM elements outside of the control you run into the nasty situation of destroying those bindings when the object is destroyed. Now if we could reli on programmers to be good little programmers then not a problem but that is not how you should develop a widget, it should be self encased.

Now why the body element you say. Well it turns out that despite what mozilla docs say, the onresize event does not fire on any dom object, only on the body element. This means that if we are going to do this then we will always bind to the body element for consistency. Luckily Ruben provided me with a Javeline base class solution for this, no surprise there, which means we will allow for mixed column formats as orginally planned for.

So today I will complete the resizing issue and work on "Sticky" columns. There has to be a better name for a column that is fixed to the right border, sticky column sounds a bit naughty to me ;-)

I also promise to get around to updated the CSS/HTML Implementation document.

Javeline Datagrid

A short time ago I developed a datagrid control which I am now in the process of moving into the Javeline framework. This page will provide a step by step process by which I create the widget. If have divided the creation of the widget into several documents that explain the thought processes in detail.

This is an ongoing project at the moment so if a page does not show up it is most likely because I am feverishly changing something. So best to refresh often I say.

Building a Datagrid Control

CSS/HTML Implementation
This document provides a detailed overview of the document object model of the data grid and how it is put together in order to be cross browser compliant.

Dealing with Column Percentage and Sizing
Reviews cross browser column resizing issues. As much a discussion primer about how to support functionality and what functionality should actually be put in place.

Managing Column Resize with Javascript
A Javascript implementation of resizing columns.

The Column as a Child Class: The Teething Process
Lists the public and private methods and properties of the column object

Datagird Methods and Properties
Lists the public and private methods and properties of the datagrid object

Datagrid Component: Griding my Teeth and Stuck in Gridlock