⚠ 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

Search Field & Pagination is not working



likhon3k
  • profile picture
  • Member

Posted 02 February 2013 - 16:41 PM

I found a problem on search option & pagination. I can input, view, edit data by GC library. But when I want to use search option & pagination then it is not working. I am using GC 1.3.3 version.

this feature is not working on my created table. but it is working on all other example table.

[attachment=456:44.jpg]

I tried to find out but failed. All link of example database it is working except my table.

please give a solution.

likhon3k
  • profile picture
  • Member

Posted 02 February 2013 - 17:22 PM

datatables > theme is working fine. but what is the problem for flexigrid not understand.I am using on default example controller. all other default function's flexigrid is working except my one. please give a solution.

victor
  • profile picture
  • Member

Posted 02 February 2013 - 23:32 PM

show your code

likhon3k
  • profile picture
  • Member

Posted 03 February 2013 - 18:00 PM

show your code

 


Thanks Victor, I found few solution to view ur solution from other posts. I found my problem also.

 

I am using session data to show username who logged in my application. I am using custom login controller.

 

when i use this code:

 

 

        $data=$this->session->all_userdata();
        $username=$data['username'];

       echo 'Logged In username: '.$username;


 

 

I found that pagination and search option was not working. when ever i remove that three line code, then pagination and search option is working fine. this code is problem on flexigrid theme only, but datatables working fine.

 

can you please give me how to show username and use session data?


victor
  • profile picture
  • Member

Posted 03 February 2013 - 21:54 PM

what error do you have? Have a look at error panel in your browser.


likhon3k
  • profile picture
  • Member

Posted 05 February 2013 - 03:44 AM

what error do you have? Have a look at error panel in your browser.

 


If I try to search anything, then search option is searching but nothing happens. search option is not find data and it stay on same page. See the below image.

 

[attachment=457:44.jpg]

 

In pagination, If I click on pagination button, 1>2>3 then pagination number is chaging but data is not changing, like.

 

suppose, I have 30 data (1 to 30), Every page showing 10 data. If I click on 2nd page it should show 11 to 20 nos data. but it stay on previous page means its all time showing 1 to 10 nos data. same as 3rd page.

 

this problem arise whenever i use the below code:

     

        $data=$this->session->all_userdata();
        $username=$data['username'];
        echo 'Logged In username: '.$username;
 

victor
  • profile picture
  • Member

Posted 05 February 2013 - 08:34 AM

Show full controller code! And what error do you get from firebug? Which tools do you use to debug js code?


likhon3k
  • profile picture
  • Member

Posted 08 February 2013 - 13:11 PM

Show full controller code! And what error do you get from firebug? Which tools do you use to debug js code?

 

see my code:

 

 

function files_management()
    {

        $data=$this->session->all_userdata();
        echo 'Logged In username: '.$data['username'];
        $username=$data['username'];
        
        $crud = new grocery_CRUD();

            //$crud->set_theme('datatables');
            $crud->set_table('files');
            $crud->unset_columns('description');
            $crud->unset_fields('username');
             $crud->callback_after_insert(array($this, 'log_user_after_insert'));
            $crud->callback_after_update(array($this, 'log_user_after_update'));

            $crud->set_field_upload('upload_file_url','assets/uploads/files');
            
            $output = $crud->render();

            $this->_example_output($output);
    }

 

 

1) if i use $crud->set_theme('datatables'); this line then searching and pagination working fine with these code. but its problem on flexigrid.

 

2) if i remove

        $data=$this->session->all_userdata();
        echo 'Logged In username: '.$data['username'];
        $username=$data['username'];

 

 these code, then searching and pagination of flexigrid and datatables theme working fine.

 

3)I am using firebug.


victor
  • profile picture
  • Member

Posted 08 February 2013 - 13:22 PM

you can't use "echo" in controller!

 

read the user guard http://ellislab.com/codeigniter/user-guide/general/views.html

it isn't possible use "echo" in the controller.

You should transmit your data to the view


likhon3k
  • profile picture
  • Member

Posted 08 February 2013 - 17:52 PM

you can't use "echo" in controller!

 

read the user guard http://ellislab.com/codeigniter/user-guide/general/views.html

it isn't possible use "echo" in the controller.

You should transmit your data to the view

 

You can use echo command in codeigniter.  please check it: http://ellislab.com/codeigniter/user-guide/general/controllers.html#what

I used echo command in controller on several project.

Please check Let's try it:  Hello World! 
<?php
class Blog extends CI_Controller {

    public function index()
    {
        echo 'Hello World!';
    }
}
?>
 

 

Thank you for your reply, I removed it and everything is fine. but didn't understand why it was not working. echo can be used in controller.

 

If it is bug then please solve it, I told you, my code was fine if I used datatable theme and its problem on flexigrid. if i use $crud->set_theme('datatables'); this line then everything is working fine.

 

 

anyways, thank you very much for your quick reply with the solution :)


victor
  • profile picture
  • Member

Posted 08 February 2013 - 17:55 PM

You can use echo command in codeigniter.

Only if you don't use a view! 


likhon3k
  • profile picture
  • Member

Posted 08 February 2013 - 18:03 PM

Only if you don't use a view! 

 

ok. Thank you very much for your solution :). but why its working on datatables theme?


victor
  • profile picture
  • Member

Posted 08 February 2013 - 18:05 PM

1)if you use a template (in your case you use it) and if you use compress output you can't use echo command.

2) This library use JSON data and in your case answer from server will be :

your_nicname{json:data}. it's a bad practice. 

3) and your html isn't valid

 

your_nicname 

<html>

....

</html>


victor
  • profile picture
  • Member

Posted 08 February 2013 - 18:09 PM

ok. Thank you very much for your solution :). but why its working on datatables theme?

The datatables dont use AJAX! All search operations only use JavaScript for it.


likhon3k
  • profile picture
  • Member

Posted 08 February 2013 - 18:10 PM

Thank You.


victor
  • profile picture
  • Member

Posted 08 February 2013 - 18:12 PM

ok. Thank you very much for your solution :). but why its working on datatables theme?

The datatables don't use AJAX! All search operations only use JavaScript for it.