Hi, I’ve been having a problem with Flexigrid on CI on my current project. I use a select query with a subquery, and for some reason I cannot sort my data by the last two columns.
From ajax_model.php
$this->db->select("i.item_number, i.item_name, SUM(si.quantity_purchased) AS quantity, SUM(si.item_total_cost) AS revenue, SUM(si.item_total_cost) / (SELECT SUM(total_sales) AS sum FROM submissions WHERE date_submitted = '" . $date . "') AS percent", false);
$this->db->where("s.date = '" . $date . "' AND s.id = si.sale_id AND si.item_id = i.id", null, false);
$this->db->group_by("i.item_name", false);
$this->db->from("items i, sales s, sales_items si", false);
From ajax.php (controller)
$valid_fields = array('i.item_number', 'i.item_name', 'quantity', 'revenue', 'percent');
From the Flexigrid controller
$colModel['i.item_number'] = array('SKU/Barcode', 150, TRUE, 'left', 2);
$colModel['i.item_name'] = array('Name', 250, TRUE, 'left', 1);
$colModel['quantity'] = array('Sold', 50, TRUE, 'center', 0);
$colModel['revenue'] = array('Revenue', 160, TRUE, 'right', 0);
$colModel['percent'] = array('% of Gross', 75, TRUE, 'center', 0);
The grid is perfectly sortable by item number, name, and quantity. However whenever I try to sort it by revenue or percent, it gets stuck refreshing, with the “Processing, please wait…” message. Hope this can be resolved, since I really love using this implementation. Saved hours generating tables. 😊
Thanks!