Jump to content


groceryCRUD and Bootstrap

datepicker

  • Please log in to reply
8 replies to this topic

#1 Jan from Hamburg

Jan from Hamburg

    Newbie

  • Members
  • Pip
  • 8 posts

Posted 02 March 2012 - 04:00 PM

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

#2 web-johnny

web-johnny

    grocery CRUD Author

  • Administrators
  • 1,150 posts
  • LocationLondon

Posted 02 March 2012 - 10: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.grocerycr...ange_field_type
Posted Image

#3 Jan from Hamburg

Jan from Hamburg

    Newbie

  • Members
  • Pip
  • 8 posts

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.
Posted Image

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

#4 Jan from Hamburg

Jan from Hamburg

    Newbie

  • Members
  • Pip
  • 8 posts

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"

#5 web-johnny

web-johnny

    grocery CRUD Author

  • Administrators
  • 1,150 posts
  • LocationLondon

Posted 04 March 2012 - 01: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.grocerycr...on/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.
Posted Image

#6 Jan from Hamburg

Jan from Hamburg

    Newbie

  • Members
  • Pip
  • 8 posts

Posted 07 March 2012 - 08: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)

#7 web-johnny

web-johnny

    grocery CRUD Author

  • Administrators
  • 1,150 posts
  • LocationLondon

Posted 07 March 2012 - 09: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: https://github.com/s...726238f599e3289 ) 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.
Posted Image

#8 Jan from Hamburg

Jan from Hamburg

    Newbie

  • Members
  • Pip
  • 8 posts

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.

#9 web-johnny

web-johnny

    grocery CRUD Author

  • Administrators
  • 1,150 posts
  • LocationLondon

Posted 08 March 2012 - 07:19 PM

Yeap that's right.
Posted Image





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users