Page 1 of 1

Customise "copy set" action?

PostPosted: Wed Apr 22, 2009 2:27 am
by RossC
Hi all,

Might be a bit of an obvious question (or maybe not...!) but is there a way to customise the copy set action?

Specifically I'd like to customise the way the list of records is rendered, so that rather than just displaying the record title, all rows are displayed (our titles are summaries, and don't include enough info for the user to make a decision on which records to copy).

Thanks in advance!

Ross

PostPosted: Tue Apr 28, 2009 12:30 pm
by shannah
Probably the easiest way to do this is to override the copy_replace.html template. You can find this template in Dataface/templates. Just copy it into your application's templates directory and make customizations as necessary.

In particular, you'll notice a section like:
Code: Select all
<table>
      <thead>
         <tr>
            <th>Title</th>
            {foreach from=$columns item="column"}
               <th>{$column.widget.label}</th>
            {/foreach}
         </tr>
      </thead>
      <tbody>
     {foreach from=$records item=record}
        <tr><td>{$record->getTitle()}</td>
        {foreach from=$columns item="column"}
           <td>{$record->preview($column.name)}</td>
        {/foreach}
        </tr>
        
     {/foreach}
     </tbody>
     </table>


This is just set to show the title and primary keys of each record. You could also add a "description" column to show you the record description with some more specific information:

Code: Select all
<table>
      <thead>
         <tr>
            <th>Title</th>
                        <th>Description</th>
            {foreach from=$columns item="column"}
               <th>{$column.widget.label}</th>
            {/foreach}
         </tr>
      </thead>
      <tbody>
     {foreach from=$records item=record}
        <tr><td>{$record->getTitle()}</td>
               <td>{$record->getDescription()}</td>
        {foreach from=$columns item="column"}
           <td>{$record->preview($column.name)}</td>
        {/foreach}
        </tr>
        
     {/foreach}
     </tbody>
     </table>


You can override record descriptions in your delegate class with the getDescription() method:

Code: Select all

function getDescription(&$record){
   return "A unique description for this record: ". $record->val('id').' : '.$record->val('name');

}


Or something along those lines.

-Steve