Include to favorites
Log in Logout Register
Start Login Contact Help Photos What's new
Avanced Search
FAQ
RESULTS IN: TEXT IMAGES
 

Hello, Guest
Login  Register
Online: 136 visitors

Blogging (2)
Business (1)
Educational (2)
Gadgets (1)
Games (8)
High Tech News (1)
Internet (1)
PC (2)
PDA (0)
Science (1)
Shopping (6)
Software (1)
Wireless (1)


Browse by date

<< May 2012 >>
MonTueWedThrFriSatSun
123456
78910111213
14151617181920
21222324252627
28293031




Recent searches

Popular searches

Hot this month

Weblogs Archive


GADGETS AND GAMES DIRECTORY :: > Software Register Weblog >  Software Tech Weblogs - WEEKLYBITS.COM GADGETS AND GAMES DIRECTORY
Yahoo User Interface Blog
generated by http://wordpress.org/?v=3.0.4  en Blogger
SEND A FRIEND
Suscribing to  please login first
User: Login

Is a collection of industrial-grade JavaScript utilities and widgets that enable you to efficiently get the most out of today’s powerful web applications.
News and Articles about Designing and Developing with Yahoo! Libraries.Visit Yahoo! User Interface Blog
Address URLhttp://www.yuiblog.com/blog    Registered: 26-Apr-2008
Ads:

Send to email
Visit Ask Satyam: Row Expansion and Nested DataTables Ask Satyam: Row Expansion and Nested DataTables in Development
By Satyam
el 17-Aug-2010

Satyam (a.k.a Daniel Barreiro) is a long-time YUI contributor and one of the most prolific, generous experts in the YUI forums. He is also the author of a new book on YUI 2.8.0, YUI 2.8.0: Learning the Library. This article in the “Ask Satyam” series was suggested by Alberto Santini and Bryan Kane. Satyam will be answering several additional questions in the coming weeks here on YUIBlog as part of the series.

It’s a common problem in information architecture: You have tabular data, and you have the need to display additional information about the entity represented by each table row. Usually, this is accomplished by “expanding” the row on click or selection and showing the data directly below the chosen row. Sometimes this additional data comes in the way of a further DataTable which might also have its rows expandable into more nested levels. We call the basic use case of drilling down into a single row row expansion; when the use case involves further tabular data associated with each row, the feature is described as a nested DataTable.

So far there have been several serious attempts to support these features with the YUI 2 DataTable. DataTable’s own list of examples includes a Row Expansion example by Eric Gelinas. John Lindal presented his Treeble in a YUI Blog article some time ago with a version for YUI 3 in the Gallery. I also tried with my NestedDataTable project.

None of these solutions is completely satisfactory and the question tends to recur; in fact, two people asked for it as part of the Ask Satyam series. In this article, I’ll dive in again and explore strategies and options for dealing with row expansion and nested DataTables.

A few issues to consider

DataTable makes a couple of very basic assumptions. One is that the ordinal position of a Record corresponds to the same ordinal position of a row within the <tbody> of the markup. I count 17 occurrences of property sectionRowIndex which returns the ordinal number of a <tr> element within its section (that is, within the <tbody>, <thead> or <tfoot> where it is contained). There are also many occurrences where the ordinal position of the Record is used as an index into the array of rows. For example, in the Row Expansion example, let it run to the end, expand any row about half-way to the table and then execute the following two statements in the debugging console:

YAHOO.example.Basic.oDT.getTrEl(YAHOO.example.Basic.oDT.getRecord(17)).id
YAHOO.example.Basic.oDT.getNextTrEl(YAHOO.example.Basic.oDT.getRecord(17)).id

Both will show yui-rec17 as the answer, which is not correct since the second statement should return the id of the next row. If you do the same with no rows expanded or using a low number, before the expanded row, the second statement will correctly return yui-rec18.

Obviously, all examples listed work in their basic form; the “bug” demonstrated above amounts to a trick. If your application stays within safe boundaries, you are fine. However, a feature added to your application at a later time, one that makes deeper assumptions about how the DataTable’s internals are operating, may lead to some problems. (For what it’s worth, DataTable is very robust. Its built-in functionality is pretty safe, it sorts columns, edits cells, selects and highlights fine, as far as I tested it. I wasn’t able to break its most popular built-in features.)

Nesting structures within the DataTable also invites some other complications: Clicking somewhere in an expanded custom row might be troublesome, since the click on the nested element would bubble up to the containing DataTable where it can mess things up. You must remember this point when listening to events such as cellClickEvent on the parent table since the target cell reported might not belong to the parent table but to a nested one ? so fetching the Record or Column for that cell may fail.

Finally, there are some conceptual issues. What does getNextTrEl mean? Does it include only DataTable’s own rows (let’s call them data rows), or should it include custom rows added later, as it does now? I would say it should only include data rows since the custom rows, being nested, are not siblings to the data rows but children and, though the HTML markup forces us to use plain <TR> elements, conceptually, they are not siblings. Then, if you somehow reach a <TR> element and ask for its corresponding Record in the containing DataTable using method getRecord(), if that <TR> is a custom row, what would be its corresponding Record: null (since it doesn’t belong to the containing DataTable but to the nested one) or the Record of the data row it is a child of?

How do you want the stripes on the rows? Currently, the striping logic takes even and odd rows indiscriminately, whether data rows or custom rows but perhaps you would like the custom rows to carry on the same background color as the data row to which they belong.

These are some of the aspects of row-expansion functionality that require definition; any decision on them, as long as it is consistent and predictable, would likely accommodate most use cases.

Nesting without DataTable

Of course, we might live with these restrictions, but then what is the point of bothering with the DataTable at all? If all you want is to display some nested information in a tabular form, you could simply use a regular <table> element or something like it. In fact, the YUI 3 version of Treeble (example) does exactly that; since there is not yet a YUI 3 version of DataTable to be used, it uses none at all. You might as well do the very same thing with YUI 2, like in this example, where no DataTable nor HTML <table> was used at all. Admittedly, the example is very simple and visually ugly (I’ve never claimed to be artistic); but, if that is all you care for, at least you know it won’t fail you. Just an idea you might want to evaluate when you decide on what to do.

Row Expansion with DataTable

Finally, you might really want to use a DataTable. If so, how do we go about that? Both Treeble and my own NestedDataTable nest two DataTables. Eric Gelinas, in contrast, has used another approach, which I find more flexible. He does not make any assumptions on what is going to be in the expansion. It uses a rowExpansionTemplate configuration attribute that can take either a string template or a reference to a function. The string template is processed via YAHOO.lang.substitute along with the data from the Record object for the row about to be expanded. We already know that we don’t need to define in the column definitions array all the fields we have read with the DataSource; we can keep extra DataSource fields in reserve for later use. The template mechanism lets us display in the expansion row those other fields for which we didn’t have space in the regular row. The example lists picture names from Flickr, images which might be too big to show in the main DataTable. The fields to assemble the URL pointing to those pictures are loaded from the start. Upon row expansion, those bits are put together to built an <img> tag and the thumbnail for the picture is shown in the expansion row.

Now, if we set rowExpansionTemplate to a function reference, then we get all the flexibility we might possibly want. I used that idea in this example, but with a somewhat different rowexpansion.js file. The original was more focused on using the string template and it assumed that the expansion row could be destroyed and rebuilt at any time at no cost. That is not the case when the expansion is something more complex, such as a DataTable with further DataTables nested within. Every time a column is sorted, DataTable will delete all rows and start anew, which would be tremendously expensive with complex content if it was to be deleted and reconstructed as well. Instead, what I do is to keep a reference to the expansion row in the expansion state object (see description in method getExpansionState), which is stored in the Record of the parent table. This data is not deleted, and as a result it’s much more efficient to restore that same row whenever the parent row is re-rendered.

Sometimes, however, the parent rows will be deleted on purpose or the parent DataTable reloaded from the server with, possibly, different data which requires the children to be refreshed. I need to explicitly delete the child rows in such cases because otherwise they would remain in memory as zombies. Thus, I override several methods (deleteRow, deleteRows, initializeTable, destroy) and delete the nested content before its parent Record is deleted. Deleting, however, is not enough, since the content might need some more elaborate means of disposal. As with many complex components, DataTable has a destroy method which needs to be called to fully clear the instance and its associated events. I added the rowExpansionDestroyEvent event to signal that the nested row is about to be destroyed, thus allowing the developer to handle the content as required. For example:

albumDT.on(‘rowExpansionDestroyEvent’, function (state) {
state[NESTED_DT].destroy();
});

All events receive the state object as their single argument. Here, I use the reference to the nested DataTable which I stored under a property name of my own (NESTED_DT) and call its destroy method.

RowExpansionDataTable adds the column that triggers row expansion automatically and also listens to clicks on that column. You don’t need to do anything for that column to show up and be active. It always adds it on the left hand side by using this simple code in the constructor:

var REDT = function(elContainer,aColumnDefs,oDataSource,oConfigs) {

aColumnDefs.unshift({
key:ROW_EXPANSION,
label:”,
className:CLASS_TRIGGER
});
REDT.superclass.constructor.call(this, elContainer,aColumnDefs,oDataSource,oConfigs);
};

YAHOO.widget.RowExpansionDataTable = REDT;

RowExpansionDataTable also sets a listener for cellClickEvent and checks if the column clicked is the one with its key set to the value stored in constant ROW_EXPANSION; there is no need for us to respond to that event, although we may want to set up further listeners for our own purposes on other columns.

Though the basis of my rowexpansion.js file is Eric Gelinas’s work, there are also many differences. I changed many of the variable, method and property names to conform to the standard naming conventions and fixed plenty of errors flagged by JSLint. In its basics, however, the code is still Eric’s.

The example is well commented and described after the sample table; the rowexpansion.js file is easy to follow and its API Docs are also available.

Overlaying children

Another alternative to adding rows is to make the expansion float above the parent row. I have used this in my own NestedDataTable example. This example also uses YQL tables via YQLDataSource and, as I mentioned in the previous article, the YQL Artists search table is somewhat clumsy to use along with YUI 2 AutoComplete as it won’t bring back partial matches with artist names.

Here, when you expand a row, a container <div> is created and appended to the document body. The container uses absolute positioning and is moved to overlap the row right below the one being expanded. The container thus covers the rows next to the one being expanded so, the height of this row is increased to make space for the overlapping container.

This mechanism spares us from the two issues I mentioned before: no row is added to the DataTable, the ordinal positions of Records and Rows match at all times and events can’t bubble from the containers to the DataTable since they are not descendants of the DataTable. However, maintaining the position of the containers requires paying attention to several events and recalculating their position. Sorting the main table with several children open will move all the containers to their new positions with ease, and so will resizing the browser window.

This example uses just two levels of nesting while the RowExpansionDataTable example could be expanded to any limit. I have tried to combine the two and I see no theoretical reason why it would not succeed; however, in trying to do so I found the example got so complex that it was hard to describe in a blog article of any reasonable size. The example, as it is, has complete control over the parent and child tables, knows when they expand or contract, move, get redrawn or change in any other way, and can easily access any of them and adjust their layout. In trying to extend this to any number of levels, I found that communicating all those changes up and down the hierarchy of nested components, not all of them necessarily DataTables, was hard, with changes deep in one branch possibly affecting nested components on other branches.

The complexity lies not so much in communicating those changes up and down and acting on them as in trying to provide standard interfaces for generic child elements to participate. If you have full control over the several containers and their content, it should be manageable; however, it would only make sense to do so if the RowExpansionDataTable fails in some particular application, as I admit it may, and cannot be fixed easily.

Conclusion

You don’t always need real DataTables to have tables nested inside each other, but if you do, my RowExpansionDataTable is a good choice, besides being a good example on how to extend DataTable. It has some issues, which I described so that if you bump into them, you know where to look as you work around them. DataTable itself is amazingly robust and handles itself quite nicely. Overlapping content in the DataTable is also a possible solution, if signaling the changes in size and position of the children can be solved efficiently, though it is hard to do in a generic component ? and I didn’t try to do so here. Neither did I try a version inheriting from ScrollingDataTable; it is not that I forgot, but rather that I know it is not a trivial undertaking.



Read 38 times

Suscribing to  please login first
Ask Satyam: Row Expansion and Nested DataTables -  Tech Weblogs - WEEKLYBITS.COM  Blogger Is a collection of i

Photologs

Yahoo User Interface Blog Blogger

Is a collection of industrial-grade JavaScript utilities and widgets that enable you to efficiently get the most out of today’s powerful web applications. Yahoo! User Interface Blog News and Articles about Designing and Developing wiht Yahoo! Libraries.

Ask Satyam: Row Expansion and Nested DataTables
Satyam (a.k.a Daniel Barreiro) is a long-time YUI contributor and one of the most prolific, generous experts in the YUI forums. He is also the author of a new book on YUI 2.8.0, YUI 2.8.0: Learning the Library. This article in the “Ask Satyam” series was suggested by Alberto Santini and Bryan Kane. [...] [..] Read complete article
Subscribe to Ask Satyam: Row Expansion and Nested DataTables
Published 17-Aug-2010 by Satyam in Development
Read 38 times. More hits in More articles Ask Satyam: Row Expansion and Nested DataTables Images about Ask Satyam: Row Expansion and Nested DataTables
Yahoo User Interface Blog Blogger

Is a collection of industrial-grade JavaScript utilities and widgets that enable you to efficiently get the most out of today’s powerful web applications. Yahoo! User Interface Blog News and Articles about Designing and Developing wiht Yahoo! Libraries.

Ask Satyam: Using YQL and YUI with YQLDataSource
Satyam (a.k.a Daniel Barreiro) is a long-time YUI contributor and one of the most prolific, generous experts in the YUI forums. He is also the author of a new book on YUI 2.8.0, YUI 2.8.0: Learning the Library. This article in the “Ask Satyam” series was suggested by Mike Hatfield. Satyam will be [...] [..] Read complete article
Subscribe to Ask Satyam: Row Expansion and Nested DataTables
Published 09-Aug-2010 by Satyam in DevelopmentyqlYQLDataSourceyui
Read 20 times. More hits in More articles Ask Satyam: Using YQL and YUI with YQLDataSource Images about Ask Satyam: Using YQL and YUI with YQLDataSource
Yahoo User Interface Blog Blogger

Is a collection of industrial-grade JavaScript utilities and widgets that enable you to efficiently get the most out of today’s powerful web applications. Yahoo! User Interface Blog News and Articles about Designing and Developing wiht Yahoo! Libraries.

Ask Satyam ? Upcoming Tutorials
We invited you to ask questions in a recent post, suggesting articles for upcoming tutorials that you’d like to see on YUIBlog ? and Packt kindly offered to send an electronic copy of my new YUI 2 book, YUI 2.8: Learning the Library. I’ve selected three questions to start working on, and you’ll see these [...] [..] Read complete article
Subscribe to Ask Satyam: Row Expansion and Nested DataTables
Published 04-Aug-2010 by Satyam in DevelopmentAsk SatyamSatyam
Read 21 times. More hits in More articles Ask Satyam ? Upcoming Tutorials Images about Ask Satyam ? Upcoming Tutorials
Yahoo User Interface Blog Blogger

Is a collection of industrial-grade JavaScript utilities and widgets that enable you to efficiently get the most out of today’s powerful web applications. Yahoo! User Interface Blog News and Articles about Designing and Developing wiht Yahoo! Libraries.

Ask Satyam: Writing Clean, Debuggable Code
Yahoo! Widget for JSLint - Ask Satyam: Writing Clean, Debuggable Code Satyam (a.k.a Daniel Barreiro) is a long-time YUI contributor and one of the most prolific, generous experts in the YUI forums. He is also the author of a new book on YUI 2.8.0, YUI 2.8.0: Learning the Library. This article in the “Ask Satyam” series was suggested by JoeDev. While its focus (like [...] [..] Read complete article
Subscribe to Ask Satyam: Row Expansion and Nested DataTables
Published 02-Sep-2010 by Satyam in DevelopmentdebuggingSatyamyui 2
Read 22 times. More hits in More articles Ask Satyam: Writing Clean, Debuggable Code Images about Ask Satyam: Writing Clean, Debuggable Code
Yahoo User Interface Blog Blogger

Is a collection of industrial-grade JavaScript utilities and widgets that enable you to efficiently get the most out of today’s powerful web applications. Yahoo! User Interface Blog News and Articles about Designing and Developing wiht Yahoo! Libraries.

Ask Satyam ? and Be Eligible for a Free Copy of the New YUI 2.8 Book from Packt
Satyam (Daniel Barreiro) wrote last week about his experience writing YUI 2.8: Learning the Library, the new YUI 2 volume now available from Packt. Packt has generously offered a few free electronic copies to YUIBlog readers. Suggest a question or tutorial you’d like to see from Satyam on a YUI 2.8-related topic as a comment [...] [..] Read complete article
Subscribe to Ask Satyam: Row Expansion and Nested DataTables
Published 29-Jul-2010 by Eric Miraglia in Development
Read 27 times. More hits in More articles Ask Satyam ? and Be Eligible for a Free Copy of the New YUI 2.8 Book from Packt Images about Ask Satyam ? and Be Eligible for a Free Copy of the New YUI 2.8 Book from Packt
Kotaku`s The Gamers Guide Blogger

XBOX 360 Gamers Weblog Gossip, news and leaks for obsessive gamers Kotaku As if you don't waste enough of your time in a gamer's haze, here's Kotaku: a gamer's guide that goes beyond the press release. Gossip, cheats, criticism, design, nostalgia, pred

New S.T.A.L.K.E.R. Expansion Confirmed [PC]
Click here to read A Number That Is Too Large - A Number That Is Too Large [Stats] S.T.A.L.K.E.R. developers GSC Game World have officially announced that they're working on "Call of Pripyat", the 2007 open-world shooter's second standalone expansion. Due for release on PC this fall/autumn, CoP is set directly after the event [..] Read complete article
Subscribe to Ask Satyam: Row Expansion and Nested DataTables
Published 30-Apr-2009 by Luke Plunkett in PC GSC GameWorldNewsS.T.A.L.K.E.R.
Read 20 times. More hits in More articles  New S.T.A.L.K.E.R. Expansion Confirmed [PC] Images about  New S.T.A.L.K.E.R. Expansion Confirmed [PC]
Kotaku`s The Gamers Guide Blogger

XBOX 360 Gamers Weblog Gossip, news and leaks for obsessive gamers Kotaku As if you don't waste enough of your time in a gamer's haze, here's Kotaku: a gamer's guide that goes beyond the press release. Gossip, cheats, criticism, design, nostalgia, pred

S.T.A.L.K.E.R. Getting Second Expansion, Sequel [PC]
Click here to read Final Fantasy Composer Blues News has spotted an interview on a Russian web site that reveals plans for not only a second S.T.A.L.K.E.R. expansion, but for a full-blown sequel as well. The website - whose name my keyboard just can't reproduce - had an interview with GSC's Sergey Grigor [..] Read complete article
Subscribe to Ask Satyam: Row Expansion and Nested DataTables
Published 10-Apr-2009 by Luke Plunkett in PC GSC News S.T.A.L.K.E.R.
Read 22 times. More hits in More articles  S.T.A.L.K.E.R. Getting Second Expansion, Sequel [PC] Images about  S.T.A.L.K.E.R. Getting Second Expansion, Sequel [PC]
Kotaku`s The Gamers Guide Blogger

XBOX 360 Gamers Weblog Gossip, news and leaks for obsessive gamers Kotaku As if you don't waste enough of your time in a gamer's haze, here's Kotaku: a gamer's guide that goes beyond the press release. Gossip, cheats, criticism, design, nostalgia, pred

Already, ARMA II Gets An Expansion [PC]
ARMA II only just came out! And as you'd expect from such an ambitious game, is still pretty broken! Neither of which seems to matter, since an expansion for the game has already been announced. Called Operation Arrowhead, it's set three years after the events depicted in ARMA II a [..] Read complete article
Subscribe to Ask Satyam: Row Expansion and Nested DataTables
Published 14-Aug-2009 by Luke Plunkett in PC Arma IIBohemia InteractiveNews
Read 29 times. More hits in More articles  Already, ARMA II Gets An Expansion [PC] Images about  Already, ARMA II Gets An Expansion [PC]
Kotaku`s The Gamers Guide Blogger

XBOX 360 Gamers Weblog Gossip, news and leaks for obsessive gamers Kotaku As if you don't waste enough of your time in a gamer's haze, here's Kotaku: a gamer's guide that goes beyond the press release. Gossip, cheats, criticism, design, nostalgia, pred

Expansion Plans [The Moneysaver]
Click here to read Expansion Plans - Expansion Plans [The Moneysaver] StarCraft I [..] Read complete article
Subscribe to Ask Satyam: Row Expansion and Nested DataTables
Published 10-Mar-2012 by Owen Good in
Read 4 times. More hits in More articles Expansion Plans [The Moneysaver] Images about Expansion Plans [The Moneysaver]
Electronics - New Arrivals From Toys R Us Blogger

New Arrivals Electronics from Toys R Us Toys"R"Us - Electronics : New Arrivals Check out the Toys"R"Us Electronics store New Arrivals

The Sims 3 Generations Expansion Pack for PC
PC THE SIMS 3 GENERATIONS - The Sims 3 Generations Expansion Pack for PC Live Every Age to the Fullest!Enjoy a whole spectrum of rich life experiences with your Sims! Start off in the imagination-fuelled world of childhood and embrace the drama of the teen years. [..] Read complete article
Subscribe to Ask Satyam: Row Expansion and Nested DataTables
Published 13-Nov-2011 by Toys"R"U in General
Read 10 times. More hits in More articles The Sims 3 Generations Expansion Pack for PC Images about The Sims 3 Generations Expansion Pack for PC
The Boy Genius Report Blogger

The gadgets and technology weblog
Boy Genius Report

T-Mobile announces another round of 3G expansion
Image 0 en  - T-Mobile announces another round of 3G expansion Just in time for their big Android announcement on September 23, T-Mobile announced Thursday that they will expand their 3G service by mid-October to 8 additional markets, including Atlanta, Chicago, Los Angeles, Orlando, Philadelphia, Sacramento, San Francisco and Seattle. This brings the total to 21 cities with another 6 cities (Birmingham, Denver, Detroit, Kansas City, [...] [..] Read complete article
Subscribe to Ask Satyam: Row Expansion and Nested DataTables
Published 19-Sep-2008 by Kelly Hodgkins in HSDPANewsT-MobileUMTS3Glaunch
Read 23 times. More hits in More articles T-Mobile announces another round of 3G expansion Images about T-Mobile announces another round of 3G expansion

Warning We are not responsible of information posted from external feeds. Use this website at your own risk. Notice: We will not be liable for any direct or indirect loss or damage arising under this disclaimer or in connection with our website, whether arising in tort, contract, or otherwise.


Your Site here Your Site here Your site here Your site here Your site here