⚠ 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. ⚠


Get cell value from flexigrid

flexigrid cell value javascript

  • Please log in to reply
1 reply to this topic

#1 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts

Posted 12 October 2012 - 07:49 AM

I have a table shown on a flexigrid that, via a set_relation, displays some extra fields from a related table,
e.g. $this->grocery_crud->set_relation('customers_id','customers','{lastname} {firstname}');
and I am building a single record view.

How can I access this cell value (probably via javascript right?) that holds the 'customers','{lastname} {firstname}'?

#2 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts

Posted 19 October 2012 - 12:01 PM

I ended up building a new model where I pass the id, e.g. customers_id and I populate the data output array from the controller to the view!
Something like this...

controller:
$this->load->model('itemmodel');
$data['customer_name'] = $this->itemmodel->get_customer_flname_by_id('customers', $data['view']->customers_id)->row();

model:

public function get_customer_flname_by_id($table, $id)
{
$this->db->where('id', $id);
$this->db->select('fname, lname');
return $this->db->get($table);
}

view:
<tr>
<td valign=\"top\"><b>Customer's Name</b></td>
<td>" . '<a href="' . site_url('main/customer_row') . "/". $view->customers_id . '">' . $customer_name->fname . ' ' . $customer_name->lname . "</a>" . "</td>
</tr>

I hope this helps somebody!





Also tagged with one or more of these keywords: flexigrid, cell, value, javascript

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users