⚠ 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 crud loader issue?



JimRustler

JimRustler
  • profile picture
  • Member

Posted 23 November 2015 - 15:18 PM

Hello, i'm new here and i'm new using grocery crud (such amazing crud!!).

 

My problem is:

 

I'm using codeigniter, i don't like full page refreshes so i'm loading my crud table inside a div using ajax, but in the first load, buttons doesn't show correctly, it looks like this:

ed99a7fb1d.png

 

... but after several reloads (using F5, i'm captured the hash to request the required controller from server on document.ready), it shows correctly:

ef31a8ef34.png

 

My internal code (por "parametro" controller, showed in the images) is:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Parametro extends CI_Controller {

    public function __construct(){
        parent::__construct();
        $this->load->library('grocery_CRUD');
    }
    public function index(){
        if(!$this->verificarUserDataSesion()) {
            header('Location: ' . base_url());
               die();
        }
        $crud = new grocery_CRUD();
        $this->config->load('grocery_crud');
        $crud->set_theme('flexigrid');
        $crud->set_subject('Parametro del Sistema');
        $crud->set_table('parametros');
        $crud->columns('idpara','nombre','valor','login','tipo');   
        
        $crud->display_as('idpara','Codigo');
        $crud->set_relation('login','usuario','login');
        $crud->display_as('login','Usuario');
        
        $crud->field_type('tipo','dropdown',
            array('U' => 'Usuario', 'S' => 'Sistema'));
        
        $contenido= new stdClass();
        $data= new stdClass();
        
        $data=$crud->render();
        $data->titulo= 'Gestión de Parametros del Sistema';
        $this->load->view('v_crud',$data);
    }
    
    private function verificarUserDataSesion(){
        if(isset($this->session->userdata['logged_in'])){
            return true;
        }else{
            return false;
        }
    }
}
?>

Im loading it inside a div (with buttons) with this javascript (using jquery) code:

	$("#sis-usua").click(function(e) { simple_load("usuario"); });
	$("#sis-agen").click(function(e) { simple_load("agencia"); });
	$("#sis-para").click(function(e) { simple_load("parametro"); });
	
	$("#par-marc").click(function(e) { simple_load("marca"); });
	$("#par-unid").click(function(e) { simple_load("unidad"); });
	$("#par-clie").click(function(e) { simple_load("cliente"); });
	$("#par-prov").click(function(e) { simple_load("proveedor"); });
	
	function simple_load(controller){
		$("#contenido")
		.html("<center><img src=\"<?=base_url()?>img/loader-small.GIF\" style=\"margin-top:100px;\"></center>")
		.load("<?=base_url()?>" + controller);
	}

My problem is in the first image, it's not showing correctly, i have headaches trying to figure it out, also i have some questions:

  • I can preload js and css files in header and not calling it every time i load a crud table?
  • Why new styles are not applying when i refresh (or reload) ti the crud table after i modify the original flexigrid.css file, it's an ajax issue?

Please help me and sorry if my english is bad.


JimRustler

JimRustler
  • profile picture
  • Member

Posted 25 November 2015 - 03:20 AM

Well, about the design, i loaded the flexigrid.css file in my central header, and now it works correctly. I have one more question:

 

hoy can i hide the filter/search bar to just show a button in the bottom left of the crud table?, i can't find it around the web.

 

From this:

28250a263e.png

 

to show like this:

6dc82effbd.png


buoncri

buoncri
  • profile picture
  • Member

Posted 25 November 2015 - 11:13 AM

I think one way is to take the hand on the GCrud theme. Can make a copy of the actual theme and have a grid without search and then you can switch changing crud's theme.