⚠ 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 is an archived forum. ⚠

  •     

profile picture

How to access the grid values in a callback function?



tanver

tanver
  • profile picture
  • Member

Posted 09 December 2011 - 15:47 PM

I want to conditionally make certain controls on the [edit] form `read only` based on a certain value of the record, when edit form is invoked from the grid - am using datatables. I am not sure how can I retrieve and use the values of the current record?
I have used add/edit callbacks and am able to change the controls but am not sure how to access the values available in the grid - must be a childish question please bear with me.
TIA

web-johnny

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 09 December 2011 - 19:39 PM

[quote name='tanver' timestamp='1323445636' post='111']
I want to conditionally make certain controls on the [edit] form `read only` based on a certain value of the record, when edit form is invoked from the grid - am using datatables. I am not sure how can I retrieve and use the values of the current record?
I have used add/edit callbacks and am able to change the controls but am not sure how to access the values available in the grid - must be a childish question please bear with me.
TIA
[/quote]
It's not a childish question. It's actually my fault that I don't have enough documentation. It is just the second parameter of your callback . So in the example
http://www.grocerycrud.com/crud/example/callback_edit_field You can have something like this


function edit_field_callback_1($value, $primary_key)
{
$this->db->where('customer_id',$primary_key);
$result = $this->db->get('your_table')->row();
return '<input type="text" name="phone" value="'.$result->your_field.'" />'
}

tanver

tanver
  • profile picture
  • Member

Posted 09 December 2011 - 22:30 PM

Thank you so very much for your kind help, the key is that we can execute SQL Queries from within the callbacks as well.