How to get the records' URL in a custom action report?

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

Postby rbchen » Fri Apr 20, 2007 11:25 pm

Seems the framework is using the table row index to access each record from the URL. That is the row position of that record in the table. In my custom report, I run a sql query to retrive a set of rows, but how do I get the row index of each of them so I can construct the URL in my custom report.html.

Thanks,
Raymond
rbchen
 
Posts: 21
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Mon Apr 23, 2007 8:41 am

Hi Raymond,

There are a number of ways to reference records in a found set.Ê In the default list view, dataface using the row index because that allows it to refer back and forth between list view and details view without losing its place.Ê You can also reference them directly using primary keys.

If you already have a Dataface_Record object for the row in question, then you can get the url easily using the getURL() method.

e.g.

$record->getURL() : The url for the default action of that record.
$record->getURL('-action=edit') : The url for the edit form for that record.
$record->getURL('-action=foo') : The url for your custom action named foo on that record.

If you don't have your rows in a Dataface_Record object - no problem.Ê As long as your row is an associative array with at least the primary keys populated, you can do:

$record = new Dataface_Record('MyTableName', $row);

then you can do:

$record->getURL('-action=edit')

or whatever.



-Steve

--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby rbchen » Mon Apr 23, 2007 2:25 pm

Hi Steve:

Thanks for your reply, I will give it a try. Is that possible to accomplishe the same thing in the presentation layer (smarty, html template)?

Also, it we are using row index to reference a record in the list view and details view, what happen if that record is deleted by another concurrent user?

Thanks,
Raymond
rbchen
 
Posts: 21
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Mon Apr 23, 2007 4:19 pm

Hi Raymond,

1.Ê You can make all of these calls in the presentation layer:

{$record->getURL('-action=edit')}

2. It is quite easy to generate the URLs manually.Ê You just need to know Dataface's URL conventions:
http://framework.weblite.ca/about/presentations/dataface_urls-ppt-2.pdf/view
E.g. you could do something like Click here

3. Using the row index does introduce the possibility of inconsistencies when selecting a record in list view, if between requests somebody deletes one of the records (or makes changes).Ê However, I don't believe that this is a major problem.Ê Most databases are updated infrequently.Ê And even if this situation does occur, all you will see is the wrong record - but that will be obvious.. It won't cause any erroneous changes to be made to the database.

Dataface always uses primary keys when updating the database so that no mistakes happen.

Hope this answers your concern.

Best regards



Steve

--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
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 32 guests

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