Customise "copy set" action?

A place for users and developers of the Xataface to discuss and receive support.

Customise "copy set" action?

Postby RossC » Wed Apr 22, 2009 2:27 am

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
RossC
 
Posts: 4
Joined: Wed Apr 01, 2009 5:02 am

Postby shannah » Tue Apr 28, 2009 12:30 pm

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
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 11 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved