Adventures with XML and YUI and Dojo January 13, 2009 at 3:32 pm

Grids, grids, grids – everyone wants to make a cool grid rendering engine. Both YUI and Dojo seem to include out-of-the-box functionality to make a cool datagrid that’s similar to, dare I say it, .NET’s built-in grid rendering engine. But cooler, of course, and in JavaScript.

I love the grids they’ve come up with – specifically Dojo’s, where they’ve actually managed to render only the portions of the grid you are viewing until you scroll elsewhere. This makes it reasonable to support grids with rather large sets of data and save on rendering time until you need to render an area. Cool stuff.

What I’m not impressed with is how inflexible the inbound datasets are to these grids. Not a one seems to believe in complex XML anymore – all the cool kids now seem to be using JSON. Which is great if you’re writing your application from scratch and have that much control. But if you don’t, you’re sort of screwed. The XML parsing engines as they relate to datastores which can be used in grids are basically non-existant in both YUI and XML unless you have a very flat XML structure. Neither framework will go deeper then a single element without overriding the default data stores or writing your own parsing tool (for which you won’t find any directions on how to do).

It boggles my mind that XML, in particular, has such poor support when the browser itself provides such great support for XML as a data type. Aside from the obvious parsing functions required natively to parse HTML, you have XPath, XQuery and the DOMNode/DOMDocument structure itself built-in to every single browser out there. Why not adapt this data structure to work with these DataGrids using some of these available tools? It seems completely reasonable to me to allow for an XPath query to find certain nodes in a dataset and make them into your datagrid – and because we’re just talking about DOMNodes being returned you can still retain the cool functionality of editing and what not. And of course, you can pass all this good stuff back to any XHR command you wish in it’s native form.

So I guess I’m making the case for more formats (especially XML) to work with datasets inside DataGrid’s. I can only hope we’re not all force-fed JSON, because it’s not quite there yet when it comes to a reliable, expected output option from every app we may want to interact with. Sometimes we are writing a UI for a back-end that’s already been written and just needs an overhaul. Not all of us get to write something brand new and sparkling in Ruby with JSON support.

Here’s to hoping…

Leave a Reply

You must be logged in to post a comment.