23.02.2015 Views

www.it-ebooks.info

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 5<br />

On the __construct function, we are specifying a few important options about our<br />

grid class. We are setting the gridId; the default sort to be by eventDate, and we are<br />

enabling pagination and filtering.<br />

The __prepareCollection() function loads a collection of registries filtered by<br />

current customerId. This function can be used to do more complex operations in our<br />

collection too; for example, joining a secondary table to get more <strong>info</strong>rmation about<br />

the customer or another related record.<br />

Finally, by using the __prepareColumns() function, we are telling Magento which<br />

columns and attributes for our data collection should be shown and how we can<br />

render them.<br />

Now that we have created a functional grid block, we would need to do some<br />

changes to our layout XML file in order to display <strong>it</strong>. Perform the following steps:<br />

1. Open the giftregistry.xml file, which can be found at the location app/<br />

design/adminhtml/default/default/layout/.<br />

2. Make the following changes:<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

mdg_giftregistry<br />

mdg_giftregistry/adminhtml_customer_<br />

ed<strong>it</strong>_tab_giftregistry<br />

<br />

<br />

<br />

<br />

<br />

[ 143 ]<br />

<strong>www</strong>.<strong>it</strong>-<strong>ebooks</strong>.<strong>info</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!