Struts2 jqGrid DatePicker in Column Filter

320 views Asked by At

I have a jsp running Struts2 jqGrid plugin. I have enabled the filter row at the top of the grid, one of the columns is a date column and I want to be able to change the textbox at the top of the column into a DatePicker.

The id of the field I'm trying to change to a DatePicker is gs_fraudBegDt

I tried the following code at the end of my page but it doesn't seem to work:

$("#gs_fraudBegDt").datePicker();

How do I get gs_fraudBegDt to change to a DatePicker?

Any help is greatly appreciated.

1

There are 1 answers

0
user3420328 On BEST ANSWER

I figured out the solution:

Step 1: Add datepicker javascript to head tag... after the sj:head tag.

<script type="text/javascript" src="javascript/jquery.ui.datepicker.min.js"></script>

Step 2: Create a function that will be called from the sjg:gridColumn tag.

searchDatePick=function(element) {
    $(element).datepicker();
};

Step 3: Add the searchoption property to your sjg:gridColumn tag. Reference the variable name from step #2 in the dataInit section.

searchoptions="{size: 12, maxlength: 10, dataInit:searchDatePick,attr:{title:'Select the date'} }"