⚠ 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

ajax_list - 500 error. Sort problem?



jefc_uk
  • profile picture
  • Member

Posted 11 April 2012 - 18:24 PM

Hi,

First of all, am loving Grocery CRUD - is saving a lot of tedious work!

However, I do have a problem. Basically, it seems that if I perform a sort on any column in any table, and then move to a different table, I get a 500 Internal Server error and cannot move between pages, or search. If I go back to the table on which I originally performed the sort it behaves, and I get no error. Also, if I sort a new table then it is ok on that table, until I move to a different table.

It seems only to be after sorting that I get it. I can go between pages of a CRUD table, I can do searches and all is well but as soon as I do a sort I get errors on other tables, until I do a sort on them!

Bit hard to explain - hope the above is ok.

csrf_protection is set to false.

Here is an example Firebug output (ps - how come do I not see the error output below in browser?);


<!DOCTYPE html>
<html lang="en">
<head>
<title>Database Error</title>
<style type="text/css">
[removed by poster]
</style>
</head>
<body>
<div id="container">
<h1>A Database Error Occurred</h1>
<p>Error Number: 1054</p><p>Unknown column 'audit_table' in 'order clause'</p><p>SELECT admin_clients_roi.*, j306051cf.roi_type_label as s306051cf
FROM (`admin_clients_roi`)
LEFT JOIN `admin_roi_types` as j306051cf ON `j306051cf`.`roi_type_id` = `admin_clients_roi`.`roi_type`
ORDER BY `audit_table` asc
LIMIT 10</p><p>Filename: C:\Websites\proj0017\system\database\DB_driver.php</p><p>Line Number: 330</p> </div>
</body>
</html>

Thanks in advance,
Geoff

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

Posted 11 April 2012 - 21:46 PM

Did you use the set_relation_n_n? I am asking you because there is a known bug that I will try to fix it for the new version. The ordering and the searching doesn't work for set_relation_n_n fields. Perhaps it is related with this one.

If you don't use then it is weird as I don't think there is a bug with the ordering. Can you please tell me if the [color=#282828][font=helvetica, arial, sans-serif]audit_table exists at your columns? Or it is a field from a different crud table? [/font][/color]

jefc_uk
  • profile picture
  • Member

Posted 12 April 2012 - 07:32 AM

No, haven't used set_relation_n_n anywhere. Column 'audit_table' does not exists in table 'admin_clients_roi'. My best guess that it would be something to do with the way I am using the grocery crud object. The way i have it set up is I have one function in my controller (called 'table') which is passed the table name. Then this calls another function which contains a whole load of switch statements - one per table. This way you can pass any table name and even if it has not been explicictly set up then a default CRUD will render. This is my main function;

public function table($tbl)
{
// Add prefix to table name to make real table name
$tbl = "admin_$tbl";

// Get the client's db settings from file referenced in session data
require $this->session->userdata('client_db');

$this->load->database($client_db);

$this->grocery_crud->set_table($tbl);

// Put table name in session data for the view to access
$this->session->set_userdata('table', $tbl);

// Check for table specific options
$this->crud_options($tbl);

// Callbacks to write to audit table
$this->grocery_crud->callback_before_insert(array($this, 'audit_insert'));
// Writing delete / undelete operations is now called from custom delete function
$this->grocery_crud->callback_before_update(array($this, 'audit_update'));

// Over-ride delete function to hide record instead, also hide deleted column
$this->grocery_crud->callback_delete(array($this, 'delete'));
// $this->grocery_crud->unset_columns('deleted');

$data = $this->grocery_crud->render();
$this->load->view('client_admin/gcrud', $data);
}

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

Posted 12 April 2012 - 08:07 AM

Yeap this is the problem. For now you can simply just disable the cookie for every search or ordering by simply comment line 153-173 to the file assets/grocery_crud/themes/flexigrid/js/flexigrid.js more specifically :


/*
var cookie_crud_page = readCookie('crud_page_'+unique_hash);
var cookie_per_page = readCookie('per_page_'+unique_hash);
var hidden_ordering = readCookie('hidden_ordering_'+unique_hash);
var hidden_sorting = readCookie('hidden_sorting_'+unique_hash);
var cookie_search_text = readCookie('search_text_'+unique_hash);
var cookie_search_field = readCookie('search_field_'+unique_hash);
if(cookie_crud_page !== null && cookie_per_page !== null)
{
$('#crud_page').val(cookie_crud_page);
$('#per_page').val(cookie_per_page);
$('#hidden-ordering').val(hidden_ordering);
$('#hidden-sorting').val(hidden_sorting);
$('#search_text').val(cookie_search_text);
$('#search_field').val(cookie_search_field);
if(cookie_search_text !== '')
$('#quickSearchButton').trigger('click');
$('#filtering_form').trigger('submit');
}
*/

jefc_uk
  • profile picture
  • Member

Posted 12 April 2012 - 08:58 AM

That's great - thanks so much. Now onto hiding deleted (well, hidden) rows! :)

jcasanova
  • profile picture
  • Member

Posted 13 April 2012 - 13:46 PM

excelent, I just ran in to the same problem.!!

great!

Johnny GREAT work!

visioncoding
  • profile picture
  • Member

Posted 02 May 2012 - 15:36 PM

million thanks,Admin
but what about the datatables theme? how can i [color=#282828][font=helvetica, arial, sans-serif]disable the cookie for the datatables theme?[/font][/color]

thank you in advance.

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

Posted 02 May 2012 - 18:43 PM

Go to: assets/grocery_crud/themes/datatables/js/datatables.js and change:


bStateSave": true,


to


bStateSave": false,

visioncoding
  • profile picture
  • Member

Posted 03 May 2012 - 04:46 AM

thank you so much and i wanna tell you that i really love this library and i reviewed it to my team and they love it too,

thanks for the good things

bluepicaso
  • profile picture
  • Member

Posted 29 August 2012 - 07:02 AM

hey that i still have problem

$crud = new grocery_CRUD();
$crud->set_theme('flexigrid');
$crud->set_table('order');
$crud->columns('orderId', 'orderCust', 'orderDate', 'orderStatus');
$crud->change_field_type('orderId','readonly');
$crud->change_field_type('orderDiscount','hidden');
$crud->change_field_type('orderTax','hidden');
$crud->set_relation('orderCust', 'customer', 'custName');
$crud->set_relation('orderStatus', 'orderStatus', 'osStatus');
$crud->set_relation('orderType', 'orderType', 'otType');
$crud->display_as('ordeId','Order Number');

$crud->unset_edit();
$crud->unset_add();
$crud->add_action('Update Bill', base_url().'images/bill.png', 'welcome/editSoulBill');
$output = $crud->render();
$data['title'] = "Manage Products";
$data['logdIn'] = true;
$output = array_merge($data,(array)$output);
$this->_outputData($output);


when i delete the record it does not FADEOFF
the error is

[quote]
[b]A Database Error Occurred[/b]
Error Number: 1054

Unknown column 'order.osStatus'please help in 'order clause'

SELECT `order`.*, j614d97e6.custName AS s614d97e6, jc52a1db8.osStatus AS sc52a1db8, j12b62433.otType AS s12b62433
FROM (`order`)
LEFT JOIN `customer` as j614d97e6 ON `j614d97e6`.`custId` = `order`.`orderCust`
LEFT JOIN `orderStatus` as jc52a1db8 ON `jc52a1db8`.`osId` = `order`.`orderStatus`
LEFT JOIN `orderType` as j12b62433 ON `j12b62433`.`otId` = `order`.`orderType`
ORDER BY `order`.`osStatus` asc
LIMIT 25

Filename: /var/www/pioneer/models/grocery_crud_model.php
Line Number: 93
[/quote]


[size=6]WORKS WELL, Solution was Jhonny's comment number #4[/size]