Foren
How to set datePickerSelect value?
Massimiliano Del Matto, geändert vor 12 Jahren.
How to set datePickerSelect value?
New Member Beitrag: 1 Beitrittsdatum: 25.08.11 Neueste Beiträge
Hello, I'm using Alloy UI's DatePickerSelect for selecting a date in a form.
I want the select fields to be pre-populated when opening a record in update mode, so I set to true the setValue attribute (inherited from Calendar class), but nothing happens: the selected date is always today.
PS. (selecting a date works as well as saving it on the database, the problem is just on reading)
Here is my code:
Thank you in advance for for helping me!
I want the select fields to be pre-populated when opening a record in update mode, so I set to true the setValue attribute (inherited from Calendar class), but nothing happens: the selected date is always today.
PS. (selecting a date works as well as saving it on the database, the problem is just on reading)
Here is my code:
<%-- from view.jsp --%>
...
<div id="dataTrasporto">
<aui:select inlineField="true" label="" name="giorno" id="giorno" />
<aui:select inlineField="true" label="" name="mese" id="mese" />
<aui:select inlineField="true" label="" name="anno" id="anno" />
</div>
...
/**
* AUI: calendar-picker (JS)
*/
AUI().ready('aui-calendar', function(A) {
A.DataType.Date.Locale['it-IT'] = A.merge(
A.DataType.Date.Locale['en'], {
a: ['Dom', 'Lun', 'Mar', 'Mer', 'Gio', 'Ver', 'Sab'],
A: ['Domenica', 'Lunedì', 'Martedì', 'Mercoledì', 'Giovedì', 'Venerdì', 'Sabato'],
b: ['Gen', 'Feb', 'Mar', 'Apr', 'Mag', 'Giu', 'Lug', 'Ago', 'Set', 'Ott', 'Nov', 'Dic'],
B: ['Gennaio', 'Febbraio', 'Marzo', 'Aprile', 'Maggio', 'Giugno', 'Luglio', 'Agosto', 'Settembre', 'Ottobre', 'Novembre', 'Dicembre'],
c: '%a %d %b %Y %H.%M.%S %Z',
p: ['M.', 'P.'],
P: ['m.', 'p.'],
x: '%d/%m/%y',
X: '%H.%M.%S'
}
);
new A.DatePickerSelect({
srcNode: '#dataTrasporto',
appendOrder: ['d','m','y'],
dateFormat: '%d/%m/%Y',
setValue: true,
selectMultipleDates: false,
locale: 'it-IT',
dayNode: "#<portlet:namespace />giorno",
dayNodeName: "giorno",
monthNode: "#<portlet:namespace />mese",
monthNodeName: "mese",
yearNode: "#<portlet:namespace />anno",
yearNodeName: "anno"
}).render();
});
Thank you in advance for for helping me!
Muhammad Asif, geändert vor 12 Jahren.
RE: How to set datePickerSelect value?
Junior Member Beiträge: 25 Beitrittsdatum: 11.04.11 Neueste Beiträge
Define div with id of divLicenseExpDate in your page <div id="divLicenseExpDate"></div>
Then in your script put it like this (there may be some unnecessary library loads in the AUI().read())
<aui:script>
AUI().ready('aui-form-validator', 'aui-datepicker-select', 'aui-io-request','aui-calendar', 'aui-button-item', 'datatype-date' , 'aui-paginator', 'aui-dialog', 'aui-overlay-manager', 'dd-constrain', 'aui-overlay-context-panel', function(A) {
var datepicker2 = new A.DatePickerSelect({
calendar: {
dates: [ '2011/10/10' ],
dateFormat: '%y/%m/%d'
},
srcNode: '#divLicenseExpDate',
appendOrder: [ 'y', 'm', 'd' ],
dateFormat: '%y/%m/%d',
dayNodeName: 'dayNode',
monthNodeName: 'monthNode',
yearNodeName: 'yearNode',
yearRange: [ 1900, 2099 ]
})
.render();
});
</aui:script>
This has worked for me. Thanks to Eduardo the AlloyUI maker.
Regards,
Asif
Then in your script put it like this (there may be some unnecessary library loads in the AUI().read())
<aui:script>
AUI().ready('aui-form-validator', 'aui-datepicker-select', 'aui-io-request','aui-calendar', 'aui-button-item', 'datatype-date' , 'aui-paginator', 'aui-dialog', 'aui-overlay-manager', 'dd-constrain', 'aui-overlay-context-panel', function(A) {
var datepicker2 = new A.DatePickerSelect({
calendar: {
dates: [ '2011/10/10' ],
dateFormat: '%y/%m/%d'
},
srcNode: '#divLicenseExpDate',
appendOrder: [ 'y', 'm', 'd' ],
dateFormat: '%y/%m/%d',
dayNodeName: 'dayNode',
monthNodeName: 'monthNode',
yearNodeName: 'yearNode',
yearRange: [ 1900, 2099 ]
})
.render();
});
</aui:script>
This has worked for me. Thanks to Eduardo the AlloyUI maker.
Regards,
Asif