Tuesday, March 17, 2009

View the contents of a related record inside the view record tab

Say you have an abstract which belongs to a conference. The abstract to conference is a many-to-many relationship stored in a table. When you view the abstract record, you may have set the conferenceID to be a valuelist so that it displays the conference name.

Instead of just displaying the conference name, you can include an expando box beside the name. And if the user clicks on it, then the details of the conference appears and you can hide it again very quickly by clicking on the collapse button. For example:



This is a snippet of the view record of an abstract. You can see the conference name it belongs to and the expando box to the left. When you click it:



All the contents of the conference appear right. Very cool! So how does this work. It's actually pretty easy.

Start off by adding the field__htmlValue code to the delegate class (in our class it would be the Abstracts delegate class)



In line 2, we define our javascript file which will do most of the work for us. We will add this file in a bit. In line 3, we attempt to get the conference record from this record we have. You'll need to add another function to do this because the abstract record only has a conferenceID. So you can do this:



This will grab the conference record to use. Now in our scripts.js file, we add this:



And that should do it!

No comments: