Page 1 of 1

Customizing list view

PostPosted: Tue Mar 13, 2012 10:41 am
by wisni1rr
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?

Re: Customizing list view

PostPosted: Tue Mar 13, 2012 11:53 am
by shannah
The URL to a record can be obtained with:
Code: Select all
$record->getURL();

Re: Customizing list view

PostPosted: Wed Mar 14, 2012 8:55 am
by wisni1rr
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>';
        }

Re: Customizing list view

PostPosted: Wed Mar 14, 2012 10:14 am
by shannah
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

Re: Customizing list view

PostPosted: Wed Mar 14, 2012 11:42 am
by wisni1rr
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.

Re: Customizing list view

PostPosted: Wed Mar 14, 2012 12:08 pm
by shannah
Have you thought about using grafted fields for this?

Re: Customizing list view

PostPosted: Wed Mar 14, 2012 12:35 pm
by wisni1rr
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!

Re: Customizing list view

PostPosted: Thu Mar 15, 2012 12:43 pm
by wisni1rr
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...