Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: DataTables Editor DateTime picker support. #535

Closed
VictorioBerra opened this issue Jan 15, 2019 · 19 comments
Closed

Feature request: DataTables Editor DateTime picker support. #535

VictorioBerra opened this issue Jan 15, 2019 · 19 comments

Comments

@VictorioBerra
Copy link

VictorioBerra commented Jan 15, 2019

I paid for the Editor and it comes with a DateTime picker. So rather than getting yet another dependency id love to use the one I already have. Also it will help with consistency with the rest of my site.

Sample

http://live.datatables.net/mohuxobu/1/edit?html,js,output

Code

new $.fn.DataTable.Editor.DateTime($("#yadcf-filter--SomeTable-3"));

Click inside the name textbox.

Maybe I missed it, but is there some init function that gives me access to the element that YADCF creates? This would make doing stuff like that all the much easier. Although, if possible it would be nice if it was built into yadcf so I could control it just like I would with jQuery DateTimePicker. As you can see by the sample yadcf will have to tap into some events. You have to hit a key for example to trigger yadcf to perform the search even after selecting the date.

@vedmack
Copy link
Owner

vedmack commented Jan 16, 2019

@VictorioBerra what datetime picker library is being used by DT ?

@VictorioBerra
Copy link
Author

@vedmack It's his very own built right into the editor. The docs are kind of sparse unless you have an account https://editor.datatables.net/reference/field/datetime

But if you grab the trial editor here then you should be able to see the source code so you can see the options. i think it makes heavy use of the onChange event for clicks.

@vedmack
Copy link
Owner

vedmack commented Jan 17, 2019

@VictorioBerra , If you provide me with docs (events / etc) for that datetime plugin, or add some code to its init where you will modify its onchange to trigger keyup for text filter, or try adding onchange to the text filter (only when its requested by yadcf init - in case of that datetime picker for example) than I can try and work with it.
access to the element that YADCF creates ? nope, but you can select them with jquery, what kind of element you need in this case other than $("#yadcf-filter--SomeTable-3") ?

@VictorioBerra
Copy link
Author

@vedmack this should help. http://live.datatables.net/loqacefa/1/edit

The datepicker will always call onChange when a date is click. Unfortunately, it does not send any arguments to the callback BUT it does set datepicker.s.d to a new Date. Using this, you should be able to keep a reference to the date picker and incorporate it into the library.

Also, it takes a bunch of options:

  • disableDays
  • firstDay
  • hoursAvailable
  • maxDate
  • minDate
  • minutesIncrement
  • momentLocale
  • momentStrict
  • secondsIncrement
  • showWeekNumber
  • yearRange

So you may want to create a way for the user to pass those up maybe via filter_plugin_options

@VictorioBerra
Copy link
Author

And here is the nasty hack to get it to work in its current state http://live.datatables.net/punakiva/1/edit

@vedmack
Copy link
Owner

vedmack commented Jan 30, 2019

@VictorioBerra how to I access that datepicker.s.d? It looks like the best way to integrate this datepicker is to use text filter with .trigger('keyup')
that what I got till now http://live.datatables.net/punakiva/2/edit , you can look /breakpoint at the dateSelectSingle function

@VictorioBerra
Copy link
Author

@vedmack Right now it is a property on the new $.fn.DataTable.Editor.DateTime(...) instance. Ill put in a forum request for more help: https://datatables.net/forums/discussion/54642/datatables-editor-datatime-picker-onchange-event-has-no-data/p1?new=1

@VictorioBerra
Copy link
Author

@misanek
Copy link
Contributor

misanek commented Feb 15, 2019

@vedmack
Copy link
Owner

vedmack commented Feb 15, 2019

make sure that there will be events to listen to (with target element so it will be possible to tell who triggered the event)

@VictorioBerra
Copy link
Author

Is misanek Allan?

@misanek
Copy link
Contributor

misanek commented Feb 16, 2019

No, I am not :) I just follow this thread, because this feature would be useful for me too :)

@VictorioBerra
Copy link
Author

@VictorioBerra
Copy link
Author

@vedmack Its out! https://editor.datatables.net/download/1.9.0

The DateTime picker's onChange callback will now execute in the scope of the date time instance and pass two arguments: 1. The selected value (as a string) and 2. The Date() object for the selected date / time. Note this is only useful if you are using the DateTime object outside of Editor.

@vedmack
Copy link
Owner

vedmack commented Mar 9, 2019

@VictorioBerra plz provide a working jsfiddle with the new datatables code / etc...

@VictorioBerra
Copy link
Author

@vedmack Im not sure what youre asking for exactly, the code samples above should be all thats needed. Everything is the same except the onChange event now contains the selected value as a string and the selected value as a date()

http://live.datatables.net/totadepa/1/edit

See that sample and then see the console. Now I think you just need to finish the code on your side to tap into that.

@vedmack
Copy link
Owner

vedmack commented Mar 21, 2019

@VictorioBerra please take a look at this http://live.datatables.net/totadepa/1/edit and let me know how it work for you

@VictorioBerra
Copy link
Author

@vedmack This is great thanks a lot for your work on this. Really nice to lean into the Editors date picker.

Feel free to close when you deploy.

vedmack added a commit that referenced this issue Mar 27, 2019
Added DataTables Editor DateTime picker support
Added multi_select_custom_func support in exGetColumnFilterVal

#535
#562
@vedmack
Copy link
Owner

vedmack commented Mar 27, 2019

added in 0.9.4.beta.24

@vedmack vedmack closed this as completed Mar 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants