⚠ 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

Filter a Date Field by Range of dates



nick2474
  • profile picture
  • Member

Posted 13 November 2012 - 06:07 AM

Hi guys,

I need to know how can filter by range of dates in one field.

Example:

[font=courier new,courier,monospace]#Order Details[/font]
[font=courier new,courier,monospace]--------- ---------[/font]
[font=courier new,courier,monospace]10/01/2012 Customer 1[/font]
[font='courier new', courier, monospace]10/05/2012 Customer 4*[/font]
[font='courier new', courier, monospace]10/05/2012 Customer 5*[/font]
[font='courier new', courier, monospace]10/01/2012 Customer 2[/font]
[font='courier new', courier, monospace]10/02/2012 Customer 3*[/font]
[font='courier new', courier, monospace]10/01/2012 Customer 6[/font]
[font='courier new', courier, monospace]10/03/2012 Customer 3*[/font]
[font='courier new', courier, monospace]10/01/2012 Customer 6[/font]
* = Need to filter the field #Order by Date between 10/02/2012 and 10/05/2012.

Thanks for help

victor
  • profile picture
  • Member

Posted 13 November 2012 - 07:48 AM

Hi, nick2474 and welcom to the forum!

You can use the method where as solution.

sonicfive
  • profile picture
  • Member

Posted 15 July 2013 - 23:18 PM

Hi, nick2474 and welcom to the forum!

You can use the method where as solution.

My question is related, and probably this is what nick2474 needs:

 

How can I add two input fields. One for beginning date, the other for end date, then filter results based on those two parameters?

I am looking for an in deep explanation.

 

Thanks, 


davidoster
  • profile picture
  • Member

Posted 16 July 2013 - 00:30 AM

Hello and welcome to the forums [member=sonicfive].

Well we need some more information about these two input fields. Where do you get them from?

a. from a new insert on a table?

b. from other user input?

c. combination of the above?

d. some other way?

 

And then where these two fields are used in order to filter the results?

i. on the default list/grid of Grocery CRUD?

ii. during adding / editing records?

iii. some other state/situation?

 

Please be more precise in order to be able to help you out, especially when you're looking for a "deep" explanation!


ceroberoz
  • profile picture
  • Member

Posted 27 July 2013 - 18:30 PM

First, I am so sorry to revive this thread because I have the same question regarding Grocery Crud.

 



Hello and welcome to the forums [member=sonicfive].

Well we need some more information about these two input fields. Where do you get them from?

a. from a new insert on a table?

b. from other user input?

c. combination of the above?

d. some other way?

 

And then where these two fields are used in order to filter the results?

i. on the default list/grid of Grocery CRUD?

ii. during adding / editing records?

iii. some other state/situation?

 

Please be more precise in order to be able to help you out, especially when you're looking for a "deep" explanation!

I need the user input above the default grocerycrud output to enter the date range and filter them.

 

Is that possible to do with grocerycrud?

If not, any suggestions?

 

Thanks before.

- - - edited

Didn't know we had this gem here :D

http://www.grocerycrud.com/forums/topic/240-multiple-search-conditions-on-flexigrid/

Assem Abdul-Mahmood
  • profile picture
  • Member

Posted 10 August 2013 - 20:23 PM

hello  davidoster, thank you so much for your contentious help. 

I am also looking to do so, and what I want as following

 

1-  two input fields from other user inputs.One for beginning date, the other for end date, then filter results based on those two values, with date-picker that associated by defulte with GC date field .

2- I want those fields on only my transaction datatable view to filter activities, on the the header of list/grid of Grocery CRUD.

something like http://www.datatables.net/examples/plug-ins/range_filtering.html

I don't want to see it in all my datatable views.

 

another question.

 

I also want to add horizontal scroll bar similar to this http://datatables.net/release-datatables/examples/basic_init/scroll_x.html

Can you tell me where should I put this code?

 

thanks in Advance


davidoster
  • profile picture
  • Member

Posted 11 August 2013 - 05:58 AM

For questions 1,2 you need to have some sort of session variable that is set via your controller and then on your datatables js check this variable for displaying or not the date fields.

For 1,2 I would add the code that this example has under assets/grocery_crud/themes/datatables/js/datatables.js

 

For the last question again I would modify the previous file, assets/grocery_crud/themes/datatables/js/datatables.js


Assem
  • profile picture
  • Member

Posted 11 August 2013 - 14:26 PM

thank you so much David for your quick response. 

I have no previous experience in JQuery and that's my problem right now :( , so if you don't mind, could you give me a quick example for doing step 1 & 2. may this example help me more 

 

I have also tried to modify datatables.js to add

$(document).ready(function() {
$('#groceryCrudTable').dataTable( {
"sScrollX": "100%",
"sScrollXInner": "110%",
"bScrollCollapse": true
} );
} );    

I have added it to the end of the file but still not working, still my view out of my Main Div 

 

see the attached pic

 

 

 


davidoster
  • profile picture
  • Member

Posted 11 August 2013 - 22:50 PM

Well this is part of everybody's learning process. Right now I don't have the time to write out a working example like this.

Maybe someone else with more time might be able to help you.

Sorry!