⚠ 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

groceryCRUD and Bootstrap



Jan from Hamburg

Jan from Hamburg
  • profile picture
  • Member

Posted 02 March 2012 - 16:00 PM

How could I use JQuery datepicker?
Where do I have to include the lines (add-function/view)
Thank you!!!

web-johnny

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 02 March 2012 - 22:36 PM

I don't understand your question. grocery CRUD already use datepicker for all the date and date time fileds. If you though you want to force a field to be with a datapicker you just have to add:


$crud->change_field_type('my_date_field','date');


For more about the change_field_type function you can see at: http://www.grocerycrud.com/documentation/options_functions/change_field_type

Jan from Hamburg

Jan from Hamburg
  • profile picture
  • Member

Posted 04 March 2012 - 11:07 AM

Thank you for the answer. Quite impressed, how you are doing this all.

Well, my problem ist datepicker doesn't work. Also something else. May be a result by the same mistake.
All JQuery-files are there and they are connected. I can open then from browser-sourcecode, so the path seems ok.
Everything looks all right, but datepicker does not appear.
Second thing is, that I get a mysterious view after i edit something.
[img]http://jan-kube.com/where_from.png[/img]

So is that by the same cause?
Appriciate any help. Greetings from Hamburg, jan

Jan from Hamburg

Jan from Hamburg
  • profile picture
  • Member

Posted 04 March 2012 - 12:01 PM

I do also use bootstrap-framework and HVMC. I thought it might be a problem, that bootstrap and groceryCrud both use and include jquery. But when I deactivate bootstrap nothing changes (nothing but the bootstrap-design).

Error: "js_date_format is not defined"

web-johnny

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 04 March 2012 - 13:02 PM

It is for sure that your files are not called properly.

But perhaps it is more simple than that. As I see you have the index as your function. The index is a known issue of grocery CRUD ( http://www.grocerycrud.com/documentation/known-issues ) So try to move your code to another function. So for example if you have:


function index()
{
$this->grocery_crud->set_table('customers');
$this->grocery_crud->columns('customerName','phone','addressLine1','creditLimit');

$output = $this->grocery_crud->render();

$this->_example_output($output);
}


try to move it to another function named for example test or whatever but not index. Is it a known issue for grocery CRUD.


function test()
{
$this->grocery_crud->set_table('customers');
$this->grocery_crud->columns('customerName','phone','addressLine1','creditLimit');

$output = $this->grocery_crud->render();

$this->_example_output($output);
}


If this don't work can you add at the forum an attachement of the view page source of your page? Only the HTML page source of the first list page. I think I will totally understand what the problem is with is. Also please write what grocery CRUD version do you use, what Codeigniter version and what PHP version.

Jan from Hamburg

Jan from Hamburg
  • profile picture
  • Member

Posted 07 March 2012 - 20:40 PM

Dear Reader, if you do use groceryCRUD and Bootstrap, like me..
Dont't load Jquery twice. Datepicker and other things won't work any more.
So don't write in your footer
<script src="<?=base_url()?>assets/bootstrap/js/jquery.js"></script>
like normally for bootstrap.
Just not that line, the remaining JQuery-lines are ok.


(PS: Thank you for the answer above, John)

web-johnny

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 07 March 2012 - 21:13 PM

Or I have a method named unset_jquery and you can simply use it with:


$crud->unset_jquery();


The reason I created it is for similar situations as the bootstrap. When you already have the jquery inserted to your template.

But it has a bug on 1.1.8 (fixed for 1.2 you can fix it with the line 1398 at: [url="https://github.com/scoumbourdis/grocery-crud/commit/cef90a2fdd1cd8aa0870209c1726238f599e3289"]https://github.com/scoumbourdis/grocery-crud/commit/cef90a2fdd1cd8aa0870209c1726238f599e3289[/url] ) to fix it to your 1.1.8 version. So you will not have to change anything . Just add this line of code to your methods/functions.

Jan from Hamburg

Jan from Hamburg
  • profile picture
  • Member

Posted 08 March 2012 - 08:31 AM

I'm impressed! Very good!!!

So we just have to take care that

<script src="<?=base_url()?>assets/bootstrap/js/jquery.js"></script>
is in the head and not in the footer.

web-johnny

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 08 March 2012 - 19:19 PM

Yeap that's right.