⚠ In case you've missed it we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This forum is read-only and soon will be archived. ⚠


Strange behavior with callback_column

callback_column

  • Please log in to reply
4 replies to this topic

#1 Luigi Tessitore

Luigi Tessitore

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 17 January 2016 - 10:08 PM

Hi, start by apologizing for my bad English.

I have a strange problem (behavior?) with a callback_column in my primary key.

 

In my example, the DB structure is very simply:

id_key -> Tiny Int, Primary, Auto Increment

column_1 -> Varchar 128

column_2 -> Varchar 128

etc.

 

I have created a callback_column function for adding a URL link as "/my_url/my_controller/my_func/id_key"

The problem is the "modify / delete / view" action.. this URL result "bound" with the auto generated URL.

Example:

http://127.0.0.1/My_...ler/index/edit/<a href='my_other_controller/my_function/123>SOME TEXT FOR LINK</a>

 

Note:

In my callback function i have a something like:

public function _callback_my_callback($value, $row){ 
        $action="<a href='my_other_controller/my_function/$value'>SOME TEXT FOR LINK</a>";
        return $action;
}
 
I suspect that the problem can be generated from the char '
But when i try this code in other column (not primary key) this work well..
 
Anyone can help me? thanks in advice.

Luigi

 

NOTE:

I have purchased a Bootstrap Theme.. great product, but the grouping of action in "more" button is less imediate than a LINK in row.. This is why I would use a callback_column function. ;)

 

 

 

 

 



#2 Amit Shah

Amit Shah

    grocery CRUD Master

  • Advanced Member
  • PipPipPip
  • 1,192 posts

Posted 18 January 2016 - 08:56 PM

well.. u using the $value - that will always work well with the primary key but if u plan to use it with others .. u must use $row->id

or something that suites u... 

Happy GCing :)



#3 Luigi Tessitore

Luigi Tessitore

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 18 January 2016 - 10:09 PM

Hi Amit,

thank for your response.

I have changed my reference $value to $row->id, but the problem persist..

 

See pics in attachment..

 

:)

 

grocery_error.jpg

 

NOTE:

the link "ASSOCIA CLIENTE" perfectly working.. the problem is in the "Ancora [MORE]" actions!



#4 Amit Shah

Amit Shah

    grocery CRUD Master

  • Advanced Member
  • PipPipPip
  • 1,192 posts

Posted 19 January 2016 - 11:51 AM

sorry i didnt notice what you wanted to do earlier. Well i will recommend not doing it this way around - rather - u can use a add action / set the url to the 1 u need (without the id) .. id will be automatically appended to the same.

Unset the read functionality for the grid.

 

What You trying to achieve is u trying to replace the url that will be generated on your own. how can you achieve the same - u need to have set some flag to do so, pass the flag to the view (before it gets rendered .. showAddForm / ShowList / ShowEditForm .. etc) - thats where u append the flag

 

in the view - where it gets rendered, checkout the code where it generates the a href tag with the link to read...

check there - if flag is set, replace the same with the new url generated else continue with the same as it used to do...

here u gona replace the whole of a ahref tag generation - rather then just the link.

 

I know it might sound a bit head scratching ... but thats the flow u need to follow what u need to achieve (your way) .. read up stuff - 4-5 times ... u may understand even before that...!!

Sorry if my English was not awsome to explain the same out.



#5 Luigi Tessitore

Luigi Tessitore

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 20 January 2016 - 09:41 PM

Thank's Amit,

i solved using _callback function on a non-primary key column.

 

Your advice to use $row->column it was very useful!

 

I create a href tag with $row->id at the end of link..

 

:)







0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users