⚠ 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

How to use G CRUD to display search results and paginate the set_model returned values?



livewire

livewire
  • profile picture
  • Member

Posted 23 July 2012 - 15:56 PM

I’m using Grocery CRUD to display my search results. The results are displayed properly but the search and sort by columns doesn’t seem to be working.
When i search there is no results are displayed.


Secondly ..im using the set_model to use my model to grab data..

 function get_list()

{
$name = $this->session->userdata('username');

$progress=$this->db->query("SELECT * FROM (SELECT feeds.url,feeds.id,feeds.SalesID,sales_log.date, sales_log.sales_prob, sales_log.current_stage, sales_log.id AS logid FROM feeds LEFT JOIN sales_log ON sales_log.leadid = feeds.id WHERE feeds.SalesID = '$name' and feeds.archived = 0 ORDER BY sales_log.id DESC )a group by a.url order by logid desc");

$results_array=$progress->result();

return $results_array;
}


The details are displayed inside the crud table but it displays all the records (574) within that page. The details are not being paginated. How can I display only 25 records and the others paginated?

Can someone please suggest me how to fix these problems?

filipe_f_f

filipe_f_f
  • profile picture
  • Member

Posted 26 July 2012 - 13:38 PM

My friend, i have this problem today and I solved it using this solution (put it inside your model class):


function get_total_results()
{
$this->db->select('id_expositor,COD_SAFIRA,NOME_FANTASIA,RAZAO_SOCIAL');

$this->db->where('ativo', 1);

$this->db->group_by('COD_SAFIRA');

$this->db->order_by('NOME_FANTASIA', 'ASC');

return $this->db->get('tb_expositores')->num_rows();

}


it works perfect!

sistemas_dge

sistemas_dge
  • profile picture
  • Member

Posted 24 August 2012 - 16:22 PM

My Friends, I have a question on the use of a custom_model...

I need to know how to run a query from the custom_model in the controller

you can provide me an example of using set_model ??

Thanks!

carmad94

carmad94
  • profile picture
  • Member

Posted 14 August 2014 - 03:30 AM

@sistemas_dge /topic/713-how-to-use-g-crud-to-display-search-results-and-paginate-the-set-model-returned-values/

may this helps :)


carmad94

carmad94
  • profile picture
  • Member

Posted 14 August 2014 - 08:55 AM

My friend, i have this problem today and I solved it using this solution (put it inside your model class):
 

function get_total_results()
   {
    $this->db->select('id_expositor,COD_SAFIRA,NOME_FANTASIA,RAZAO_SOCIAL');

	    $this->db->where('ativo', 1);
	   
	    $this->db->group_by('COD_SAFIRA');
	   
	    $this->db->order_by('NOME_FANTASIA', 'ASC');
	   
	    return $this->db->get('tb_expositores')->num_rows();
  
   }
it works perfect!

 

 

It doesn't work for me... the lists are not paginated. Does anyone else knows how to solve this problem?


carmad94

carmad94
  • profile picture
  • Member

Posted 18 August 2014 - 07:52 AM

Now it works for me  :)  I copied the get_list function from the Grocery Crud model then add my queries...

You can refer to this post:

/topic/264-join-tables/