Page 1 of 1

In the list view, how to build a link to edit the item

PostPosted: Tue Jan 27, 2009 9:02 am
by Jean
Hi Steve,
I used renderCell() to modify the link. But I can't get the cursor value.
Code: Select all
function libelle__renderCell(&$record){

echo '<pre>';print_r($record);echo '</pre>';exit;
$app =& Dataface_Application::getInstance();
$query =& $app->getQuery();
$table =$query['-table'];
$cursor=$record->val('id_moyen');
$skip=$query['-skip'];
$cursor=$_REQUEST['-cursor'];
$limit=$query['-limit'];
$mode=$query['-mode'];

return '<a>'.$record->val('libelle').'</a>';

How can I get it ?
Thank you
Jean

PostPosted: Tue Jan 27, 2009 11:45 am
by shannah
Hi Jean,

The cursor can be retrieved from the query. It marks the position in the result set that the 'details' tab is currently showing:

Code: Select all
$query =& $app->getQuery();
echo $query['-cursor'];

PostPosted: Wed Jan 28, 2009 12:48 am
by Jean
Thank you Steve. No it does not work.
I tried
Code: Select all
$cursor=$query['-cursor'];
in my function but I have a cursor at 0.
Jean

PostPosted: Wed Jan 28, 2009 3:25 am
by Jean
The problem is that all cursor values in the $record are on 0.
Jean

PostPosted: Wed Jan 28, 2009 9:27 am
by shannah
I see. The -cursor value refers to the single position in the result set of the current record. This does not change for each row. It points to one particular record in the found set. The default is 0.

Unfortunately there is no way to get the row number from the renderCell() method at this time. I suppose that could be useful. I'll add it to a todo list for a future version.

What were you trying to accomplish with the cursor? Perhaps there is another way to do what you want to do.

-Steve

PostPosted: Wed Jan 28, 2009 10:29 am
by Jean
Thank you again, Steve. Actually, I want to replace the "browse" link in the list view by a "edit" link.
Jean

PostPosted: Wed Jan 28, 2009 11:36 am
by shannah
You can use the default_browse_action directive in the conf.ini file.

e.g. at the beginning of your conf.ini file, add
Code: Select all
default_browse_action=edit

PostPosted: Wed Jan 28, 2009 12:40 pm
by Jean
Well, much simpler :wink:
Jean