I have a JqGrid with the toolbar search enable. One of my column is a datetime column and the search field is a jquery datepicker. The problem with a datepicker is that you cannot have an empty value, but as this field is a filter it can be empty. So what id'like to do is to add a little button near the datepicker which will clear the field. Is there a way to do this, or to be able to clear the datepicker from client side.
Here is the code for the column
{ name: 'Period', index: 'Period', align: 'center', formatter: 'date', formatoptions: { newformat: 'F, Y' }, width: '70px', search: true,
searchoptions: {
dataInit: function (el) {
$(el).datepicker({
yearRange: "-5:+1",
changeMonth: true,
changeYear: true,
showButtonPanel: true,
dateFormat: 'MM, yy',
onClose: function (dateText, inst) {
var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
$(this).datepicker('disable');
$(this).datepicker('setDate', new Date(year, month, 1));
$(this).datepicker('enable');
$("#jqgCompLine")[0].triggerToolbar();
},
beforeShow: function (input, inst) {
if ((datestr = $(this).val()).length > 0) {
year = datestr.substring(datestr.length - 4, datestr.length);
month = jQuery.inArray(datestr.substring(0, datestr.length - 6), $(this).datepicker('option', 'monthNames'));
$(this).datepicker('option', 'defaultDate', new Date(year, month, 1));
$(this).datepicker('setDate', new Date(year, month, 1));
}
}
});
}
},
Thanks in advance for your help!