Hello, after update a numeric value with a callback column function the order function in flexigrid theme no work in this columm, i use grocerycrud 1.3, that can I make for this work?, thanks.
⚠ 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. ⚠
Posted 11 September 2013 - 19:47 PM
Hello, after update a numeric value with a callback column function the order function in flexigrid theme no work in this columm, i use grocerycrud 1.3, that can I make for this work?, thanks.
Posted 11 September 2013 - 20:19 PM
Can you please give us some more details please?
What doesn't work?
An example or a screen capture along with the callback function will be sufficient.
Posted 11 September 2013 - 22:03 PM
this is a image of the crud
The crud looks work fine except for the order function in the column "saldo", in all others columns work fine order in an ascending or descending order but in the column saldo when i click on the column header ever order in the same arbitrary order, never in min to max or max to min order.
this is my controller code
function column_field_saldo($value, $row)
{
$customer_id = $row->customer_id;
$this->db->where('customer_id',$customer_id);
$this->db->where('payment_type' , 'credito');
$query = $this->db->get('pos_sales');
$totales=0;
foreach ($query->result() as $row2)
{
$totales = $totales + $row2->invoice_total;
}
return $totales;
}
function editar_clientes()
{
$this->db = $this->load->database('pos_db', TRUE);
$crud = new grocery_CRUD();
$crud->set_table('pos_customers');
$crud->fields('customer_cod','customer_balance','customer_dir','customer_city','customer_state','customer_country','customer_tel','customer_active','customer_date','customer_email');
$crud->unset_columns('customer_points','customer_group_id');
$crud->display_as('customer_balance','saldo');
$crud->callback_column('customer_balance',array($this,'column_field_saldo'));
$crud->set_subject('Cliente');
$output = $crud->render();
$this->load->view('clientes',$output);
}
I try with $crud->order_by('customer_balance','desc'); but this dont work maybe because the callback change the original values of the field 'customer_balance' from the DB.
Posted 12 September 2013 - 08:19 AM
It doesn't seem anything wrong here.
Just to be on the safe side though, are you certain that all the values are numeric?
Posted 12 September 2013 - 08:22 AM
Another thing that you might want to investigate is this post by [member=amit shah].
Posted 14 September 2013 - 01:38 AM
Hi nestg
It seems that customer_balance is technically a field that dose not exists on server side. It is a field that you trying to create @runtime. In Felxigrid, it is observed, the order by also set @server side and not on client side. And since the field actually dose not exists, it will not have any effect on ordering the same. You may have order by to any other field, it shall work out. But the same shall not work out in here.
There is another option possible for you, you may opt out to go on with datatables themes. There you probably have client side sorting possible (i am sorry but have not tried it out but just assuming on my past experience)
Second option is write out a custom model that will suffice your need.
Posted 14 September 2013 - 06:26 AM
[member=amit shah], I didn't know that values of runtime columns can not be sorted! Are you sure about this?
Isn't sorting's last step (I mean reordering) done via the theme itself? If that's the case this is on client side.
Hmmm, that's interesting!
Totally forgot about this! Has John reviewed the code?