⚠ 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

View without a limit



elfuego1
  • profile picture
  • Member

Posted 18 February 2013 - 01:38 AM

Hi,

 

Is there an option in GC to turn off record limit dropdown so it would not appear at all in view and display all records in grid table?

 

I need to display all records without limitations for some views. But I wouldn't like to remove this dropdown limit for all the views - just selected few.

If there is not such a feature - could it be implemented in a future version?


victor
  • profile picture
  • Member

Posted 18 February 2013 - 08:18 AM

You can cange the GC config.

 

$config['grocery_crud_character_limiter']     = 10000000000000;

 

In the GC library this:

$data->paging_options = array('10','25','50','100',10000000000000);

 

And use jquery to hide that dropdown


elfuego1
  • profile picture
  • Member

Posted 18 February 2013 - 13:51 PM

BUT

$config['grocery_crud_character_limiter']     = 10000000000000;

 

is a system wide setting, and I'd like to remove limit ONLY on few pages using GC not all of them.

Can it be done?


victor
  • profile picture
  • Member

Posted 18 February 2013 - 15:58 PM

You can change the library.


victor
  • profile picture
  • Member

Posted 18 February 2013 - 16:24 PM

I have a solution :

change the grocery_crud.php like this:

class grocery_CRUD_Layout extends grocery_CRUD_Model_Driver {

    private $theme_path = null;
    private $views_as_string = '';
    private $echo_and_die = false;
    protected $theme = null;
    protected $default_true_false_text = array('inactive', 'active');
    protected $css_files = array();
    protected $js_files = array();

// change start
// add a new property called $paging_options
protected $paging_options = NULL;

// add a new function called set_paging_options
function set_paging_options(array $options)
{
$this->paging_options = $options;
}

// change end


//and change the showList function like this

    protected function showList($ajax = false, $state_info = null)
    {
        $data = $this->get_common_data();

        $data->order_by = $this->order_by;

        $data->types = $this->get_field_types();

        $data->list = $this->get_list();
        $data->list = $this->change_list($data->list, $data->types);
        $data->list = $this->change_list_add_actions($data->list);

        $data->total_results = $this->get_total_results();

        $data->columns = $this->get_columns();

        $data->success_message = $this->get_success_message_at_list($state_info);

        $data->primary_key = $this->get_primary_key();
        $data->add_url = $this->getAddUrl();
        $data->edit_url = $this->getEditUrl();
        $data->delete_url = $this->getDeleteUrl();
        $data->ajax_list_url = $this->getAjaxListUrl();
        $data->ajax_list_info_url = $this->getAjaxListInfoUrl();
        $data->export_url = $this->getExportToExcelUrl();
        $data->print_url = $this->getPrintUrl();
        $data->actions = $this->actions;
        $data->unique_hash = $this->get_method_hash();
        $data->order_by = $this->order_by;

        $data->unset_add = $this->unset_add;
        $data->unset_edit = $this->unset_edit;
        $data->unset_delete = $this->unset_delete;
        $data->unset_export = $this->unset_export;
        $data->unset_print = $this->unset_print;

        $default_per_page = $this->config->default_per_page;
// change start:
        $data->paging_options = $this->paging_options ? $this->paging_options : array('10', '25', '50', '100');
// end change
        $data->default_per_page = is_numeric($default_per_page) && $default_per_page > 1 && in_array($default_per_page, $data->paging_options) ? $default_per_page : 25;

        if ($data->list === false)
        {
            throw new Exception('It is impossible to get data. Please check your model and try again.', 13);
            $data->list = array();
        }

        foreach ($data->list as $num_row => $row)
        {
            $data->list[$num_row]->edit_url = $data->edit_url . '/' . $row->{$data->primary_key};
            $data->list[$num_row]->delete_url = $data->delete_url . '/' . $row->{$data->primary_key};
        }

        if (!$ajax)
        {
            $data->list_view = $this->_theme_view('list.php', $data, true);
            $this->_theme_view('list_template.php', $data);
        }
        else
        {
            $this->set_echo_and_die();
            $this->_theme_view('list.php', $data);
        }
    }

  //.....
  //......

}


How to use:

      $crud = new grocery_CRUD();
        $crud->set_table('portfolio');

        $this->config->load('grocery_crud');

        $this->config->set_item('grocery_crud_default_per_page', '10000');

        $crud->set_paging_options(array(10000));
        $crud->columns('p_name', 'p_url', 'p_active', 'p_image', 'p_alias', 'p_sort');

// ......

You can use GC as before too.


jgalak1
  • profile picture
  • Member

Posted 24 June 2020 - 22:56 PM

I'm trying to do this, and no luck.  Here's the code as I set it:

 

Grocery_CRUD.php:

class grocery_CRUD_Layout extends grocery_CRUD_Model_Driver
{
	private $theme_path 				= null;
	private $views_as_string			= '';
	private $echo_and_die				= false;
	protected $theme 					= null;
	protected $default_true_false_text 	= array('inactive' , 'active');

	protected $css_files				= array();
	protected $js_files					= array();
	protected $js_lib_files				= array();
	protected $js_config_files			= array();

        protected $paging_options           = null;

        function set_paging_options(array $options)
        {
            $this->paging_options = $options;
        }
.
.
.
	protected function showList($ajax = false, $state_info = null)
	{
		$data = $this->get_common_data();
.
.
.
		$default_per_page = $this->config->default_per_page;
                $data->paging_options = $this->config->paging_options ? $this->paging_options : array('10', '25', '50', '100', '1000');
		$data->default_per_page		= is_numeric($default_per_page) && $default_per_page >1 && in_array($default_per_page,$data->paging_options)? $default_per_page : 25;
.
.
.

and in my controller class:

        $this->config->load('grocery_crud');
        $this->config->set_item('grocery_crud_default_per_page', '1000');
        $crud->set_paging_options(array(1000));

As far as I can tell, I've copied the suggested code exactly, but I still get the "10, 25, 50, 100" options in the dropdown, nothing more.

 

Help?  I really need to increase this to 1000, but only for this one screen...