scoumbourdis / grocery-crud

Grocery CRUD is a PHP Codeigniter Framework library that creates a full functional CRUD system without the requirement of extra customisation to the JavaScripts or the CSS to do it so.
http://www.grocerycrud.com
GNU General Public License v3.0
1.01k stars 472 forks source link

The method $crud->limit doesn't work as expected. #62

Open scoumbourdis opened 12 years ago

karavanis commented 12 years ago

This may be stupid but I think than on libraries/grocery_crud.php on function get_total_results() there should be a part of code like (this code exists on get_list()):

if($this->config['crud_paging'] === true)
{
    if($this->limit === null)
    {
        $ci = &get_instance();
        $ci->load->config('grocery_crud');

        $default_per_page = $ci->config->item('grocery_crud_default_per_page');
        if(is_numeric($default_per_page) && $default_per_page >1)
        {
            $this->basic_model->limit($default_per_page);
        }
        else
        {
            $this->basic_model->limit(10);
        }
    }
    else
    {
        $this->basic_model->limit($this->limit[0],$this->limit[1]);
    }
}

This doesn't solve 100% the bug. I will search more for it when I 'll have time.

jyap808 commented 11 years ago

Hello, is it possible to take a look at this issue? It seems pretty basic functionality that should work. Thank you!

famcumplido commented 10 years ago

Hello i have the same problem and "solved" limiting the number os rows to display using $this->limit(zz) in datatables The only change i made in library grocery_crud.php was including (forcing) the condition even in datatables ($this->theme_config['crud_paging'] == false ...) That way, if you use $crud->limit(zz), the library will use zz to limit the number of rows served This is not server-side interaction because it is fixed in your code but leaves you determine if there are data than are usefull, even partially (in my case to serve the 100 more recent visits of a doctor consult)

// if($this->theme_config['crud_paging'] === true) if($this->theme_config['crud_paging'] === true || $this->limit <> null) { if($this->limit === null) { $default_per_page = $this->config->default_per_page; if(is_numeric($default_per_page) && $default_per_page >1) { $this->basic_model->limit($default_per_page); } else { $this->basic_model->limit(10); } } else { $this->basic_model->limit($this->limit[0],$this->limit[1]); } }