Customizing list view

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

Customizing list view

Postby wisni1rr » Tue Mar 13, 2012 10:41 am

Code: Select all
class table_people {
    ...
    function renderRow( &$record ){
        return '<td>'.$record->display('first_name').'</td>'.
               '<td>'.$record->display('last_name').'</td>'.
               '<td>'.$record->display('phone').'</td>';
    }
    ...
}


The code above will generate a list of the fields contents for each record. How can I make a field link to the record's view details like the default list?
wisni1rr
 
Posts: 107
Joined: Mon Feb 13, 2012 9:03 pm

Re: Customizing list view

Postby shannah » Tue Mar 13, 2012 11:53 am

The URL to a record can be obtained with:
Code: Select all
$record->getURL();
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: Customizing list view

Postby wisni1rr » Wed Mar 14, 2012 8:55 am

Thanks!

This worked.

I have now made new row headers. However they do not provide sort by default. How can I make them sort like they do at default?

Code: Select all
        function renderRowHeader(){
                 return '<th>'.'BWA_ID'.'</th>'.
                        '<th>'.'Street Number'.'</th>'.
                        '<th>'.'Street Name'.'</th>'.
                        '<th>'.'City'.'</th>'.
                        '<th>'.'State'.'</th>'.
                        '<th>'.'Zip'.'</th>';
        }
wisni1rr
 
Posts: 107
Joined: Mon Feb 13, 2012 9:03 pm

Re: Customizing list view

Postby shannah » Wed Mar 14, 2012 10:14 am

Unfortunately when you start implementing your own rows and headers, you forego some of the built-in features. You would need to add sorting yourself.
Xataface does allow you to build the link to sort on a particular column using the Dataface_Application::url() method. Xataface URL conventions will accept the -sort GET parameter as follows:
Code: Select all
-sort=colname1+asc,colname2+desc

This would sort on the column colname1 ascending as the primary sort, and colname2 descending as the secondary sort.

So if you wanted to sort on a particular column, you could build the URL with:
Code: Select all
$app = Dataface_Application::getInstance();
$url = $app->url('-sort=colname+asc')


Now, if your only goal through this whole thing was to make each cell of the table custom and linkable, why not just override the xxx__renderCell() method instead of overriding the row and the headings?

-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: Customizing list view

Postby wisni1rr » Wed Mar 14, 2012 11:42 am

Steve,

I am trying to make a custom list that will populate with some related records also (esentially a 1:1 relationship). In the default layout you can click the row header and it will sort by that column ascending/descending.

When I changed my row render the row headers were still displaying the old set of headers which were no longer logical.

I'm trying to replicate the original style and mechanics of the list but with custom fields (hiding some fields and bringing in some related record fields).

Hope that helps to clarify my intent.
wisni1rr
 
Posts: 107
Joined: Mon Feb 13, 2012 9:03 pm

Re: Customizing list view

Postby shannah » Wed Mar 14, 2012 12:08 pm

Have you thought about using grafted fields for this?
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: Customizing list view

Postby wisni1rr » Wed Mar 14, 2012 12:35 pm

No I have not. I've been struggling with the concept of grafted fields as a whole.

However, it does seem to make since in a situation such as this. I'll give it a try later and report back with my results.

Thanks again, Steve!
wisni1rr
 
Posts: 107
Joined: Mon Feb 13, 2012 9:03 pm

Re: Customizing list view

Postby wisni1rr » Thu Mar 15, 2012 12:43 pm

I have what I'm looking built(no grafted fields). The only thing I need help figuring out how to make my row headers as clickable sort buttons like the default list view.

From the looks of it, I need to append "&sort=$FieldName+asc" or "&sort=$FieldName+desc" to the URL.

Maybe it could be achieved using an if statement somehow...
wisni1rr
 
Posts: 107
Joined: Mon Feb 13, 2012 9:03 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 14 guests

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