Установите минимальные и максимальные даты для Datatables Datepicker, который будет использовать ⇐ Jquery
Установите минимальные и максимальные даты для Datatables Datepicker, который будет использовать
I'm hoping this is a very simple request and I'm just missing something obvious.
I'm using the DataTables DatePicker to allow a Date Range search and whilst it's working exactly as it should, I really want to set how far back (and forward) a user can select a date.
At the moment it allows a user to select back to 2009 and up to 2049. Ideally I'd want it so that the minimum date allowed is the first date from the data in the DataTable and then the max being the max. I'm happy to set a specific year if that isn't possible.
Can anyone help please?
Here's my code:
// Create date inputs minDate = new DateTime('#datefrom', { format: 'DD-MM-YYYY' }); maxDate = new DateTime('#dateto', { format: 'DD-MM-YYYY' }); // Custom filtering function which will search data in column four between two values DataTable.ext.search.push(function (settings, data, dataIndex) { let min = moment($('#datefrom').val(), 'DD-MM-YYYY', true).isValid() ? moment($('#datefrom').val(), 'DD-MM-YYYY').format('YYYYMMDD') : ""; let max = moment($('#dateto').val(), 'DD-MM-YYYY', true).isValid() ? moment($('#dateto').val(), 'DD-MM-YYYY').format('YYYYMMDD') : ""; var date = moment( data[2], 'DD-MM-YYYY' ).format('YYYYMMDD'); if ( max = min && date
Источник: https://stackoverflow.com/questions/781 ... ker-to-use
I'm hoping this is a very simple request and I'm just missing something obvious.
I'm using the DataTables DatePicker to allow a Date Range search and whilst it's working exactly as it should, I really want to set how far back (and forward) a user can select a date.
At the moment it allows a user to select back to 2009 and up to 2049. Ideally I'd want it so that the minimum date allowed is the first date from the data in the DataTable and then the max being the max. I'm happy to set a specific year if that isn't possible.
Can anyone help please?
Here's my code:
// Create date inputs minDate = new DateTime('#datefrom', { format: 'DD-MM-YYYY' }); maxDate = new DateTime('#dateto', { format: 'DD-MM-YYYY' }); // Custom filtering function which will search data in column four between two values DataTable.ext.search.push(function (settings, data, dataIndex) { let min = moment($('#datefrom').val(), 'DD-MM-YYYY', true).isValid() ? moment($('#datefrom').val(), 'DD-MM-YYYY').format('YYYYMMDD') : ""; let max = moment($('#dateto').val(), 'DD-MM-YYYY', true).isValid() ? moment($('#dateto').val(), 'DD-MM-YYYY').format('YYYYMMDD') : ""; var date = moment( data[2], 'DD-MM-YYYY' ).format('YYYYMMDD'); if ( max = min && date
Источник: https://stackoverflow.com/questions/781 ... ker-to-use
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Часовой пояс Wicket Datepicker «ui-datepicker-today» и «ui-datepicker-current-day»
Anonymous » » в форуме Jquery - 0 Ответы
- 62 Просмотры
-
Последнее сообщение Anonymous
-