Jump to content


callback_column weird behavior.

callback column bug link

  • Please log in to reply
8 replies to this topic

#1 fredconv

fredconv

    Member

  • Members
  • PipPip
  • 17 posts

Posted 06 September 2012 - 10:07 AM

Hi

sorry to bother but i have a new weird behavior for callback_column.

on my project controller:
  public function list_items()    {
   $crud_list = new grocery_CRUD();
   $crud_list->set_table('tbl_project');
					    $crud_list->set_subject('Project');
   $crud_list->callback_column('project_code',array($this,'callback_webpage_url'));
					    $output = $crud_list->render();
   $this->result_output($output);
  }
and the definition of the callback_webpage_url
public function callback_webpage_url($value, $row){
   return '<a href="'.site_url("projects/detail_item/".$row->project_code).'">'.$value.'</a>';
			  
  }

my problem is : the projects table "project_code" show a correct link on it but the "edit" link and on the delete link also , in the action section of each row
<a title="Edit Project" href="http://localhost........./projects/list_items/edit/&lt;a href=&quot;http://localhost:8181/backlog/index.php/projects/detail_item/p0&quot;&gt;p0&lt;/a&gt;"><span class="edit-icon"></span></a>


it seems the url passing into the link from my project_code (which is correct) is also passed to the edit link ...
how to avoid this pb please ?

thanks.

#2 victor

victor

    grocery CRUD Hero

  • Advanced Member
  • PipPipPip
  • 967 posts
  • LocationMinsk

Posted 06 September 2012 - 10:40 AM

write please table structure

#3 fredconv

fredconv

    Member

  • Members
  • PipPip
  • 17 posts

Posted 06 September 2012 - 12:43 PM

Hi.

here s my table data structure (really simple)..

1 table tbl_project
##id
project_code
shortname
description
start_time
estimated_time
...many more fields....

1table tbl_sub_projects
##id
name
description
#project_id
owner
.....

What i would like to achieve is to have one first page list of all projects but with only some fields visible, and when i click on one project code link, display first the clicked project with all details and below all the sub projects related to this project ..


thanks

#4 victor

victor

    grocery CRUD Hero

  • Advanced Member
  • PipPipPip
  • 967 posts
  • LocationMinsk

Posted 06 September 2012 - 01:31 PM

Please send me or write the mysql dump with data
I'll try to find the error.
Sorry, my english is bad))

Edited by victor, 22 November 2012 - 01:26 PM.


#5 fredconv

fredconv

    Member

  • Members
  • PipPip
  • 17 posts

Posted 10 September 2012 - 08:36 AM

Please send me or write the mysql dump with data
I'll try to find the error.
Sorry, my english is bad))
siptik@mail.ru


Mail send.
Sorry for my late reply.

Thanks for your help.

#6 victor

victor

    grocery CRUD Hero

  • Advanced Member
  • PipPipPip
  • 967 posts
  • LocationMinsk

Posted 10 September 2012 - 01:13 PM

I looked at your code and realized that you can not use callback function for primary fields, because this field will have new value. Link "edit" use the value primary fields.
You can create other primary field , for example `id ` (auto_increment ).
or
This code work fine)))
function get_list(){
$crud = new grocery_CRUD();
$crud->set_table('tbl_project');
$crud->set_subject('Project');
$crud->columns(
// add a new coloumn `code` instead of column `project_code`
'code',
'project_shortname',
'project_name',
...other fields
$crud->callback_column('code',array($this,'callback_webpage_url'));
$output = $crud->render();
$this->load->view('test',$output);
}
public function callback_webpage_url($value, $row){
return '<a href="'.base_url("index.php/functionalities/get_items_from_project/".$row->project_code).'">'.$row->project_code.'</a>';
}


#7 fredconv

fredconv

    Member

  • Members
  • PipPip
  • 17 posts

Posted 10 September 2012 - 01:19 PM

Hi

Thanks for your solution.
Since i can't change the database structure  (not mine) i ll simply change the column on which i call the callback :)
from:
$crud->callback_column('project_code',array($this,'callback_webpage_url'));
to
$crud->callback_column('project_shortname',array($this,'callback_webpage_url'));


Thank you :)


PS: Did i miss the info saying the call back should not be called on a primary key ?  (ok normally, primary key should not be change  :P, and the database strucutre is a bit weird  ... *emergency evade process engaged* :D )  )

#8 victor

victor

    grocery CRUD Hero

  • Advanced Member
  • PipPipPip
  • 967 posts
  • LocationMinsk

Posted 10 September 2012 - 01:34 PM

The column `code` no need to create in database. this column is dynamically created. Use my code and you will see this. Structure does not change.
Sorry my English is bad.
If this field is not in the table structure, dynamically create a new column in table list. For this column can use callback function.

Edited by victor, 10 September 2012 - 03:51 PM.


#9 fredconv

fredconv

    Member

  • Members
  • PipPip
  • 17 posts

Posted 10 September 2012 - 01:46 PM

Ha ok
I understand now, add a new column for the display, put the project code in it , so i can call the callback function on this new column.
Great .

Thanks for this solution :)





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users