Dialog MVC 2上有多个JQuery.datepicker

时间:2012-03-10 17:15:56

标签: jquery-ui asp.net-mvc-2

我目前正在运行以下代码:

<script type="text/javascript">
$(document).ready(function() {
    var updateDialog = {
        url: '<%= Url.Action("ABM", "Periodo") %>'
            , closeAfterAdd: true
            , closeAfterEdit: true
            , modal: true
            , afterShowForm: function(formId) {
                $("#fecha_inicio").datepicker({ autoSize: true, showOn: 'both', dateFormat: 'dd/mm/yy' });
                $("#fecha_fin").datepicker({ autoSize: true, showOn: 'both', dateFormat: 'dd/mm/yy' });
            }             
            , onclickSubmit: function(params) {
                var ajaxData = {};
                var list = $("#list");
                var selectedRow = list.getGridParam("selrow");
                rowData = list.getRowData(selectedRow);
                ajaxData = { periodoNum: rowData.periodoId };
                return ajaxData;
            }
            , width: "400"
    };
    $.jgrid.nav.addtext = "Agregar";
    $.jgrid.nav.edittext = "Editar";
    $.jgrid.nav.deltext = "Borrar";
    $.jgrid.edit.addCaption = "Agregar Periodo";
    $.jgrid.edit.editCaption = "Editar Periodo";
    $.jgrid.del.caption = "Borrar Periodo";
    $.jgrid.del.msg = "Borrar el periodo seleccionado?";
    $("#list").jqGrid({
        url: '<%= Url.Action("List", "Periodo") %>',
        datatype: 'json',
        mtype: 'GET',
        colNames: ['Número', 'Desde Fecha', 'Hasta Fecha', 'Activo'],
        colModel: [
                { name: 'periodoId', index: 'periodoId', width: 40, align: 'left', editable: false, editrules: { edithidden: false }, hidedlg: true, hidden: true },
                { name: 'fecha_inicio', index: 'fecha_inicio', formatter: 'date', datefmt: 'd/m/Y', width: 100, align: 'left', editable: true, edittype: 'text', editoptions: { size: 10, maxlength: 10 }, editrules: { required: true }, formoptions: { elmsuffix: ' *'} },
                { name: 'fecha_fin', index: 'fecha_fin', formatter: 'date', datefmt: 'd/m/Y', width: 100, align: 'left', editable: true, edittype: 'text', editoptions: { size: 10, maxlength: 10 }, editrules: { required: true }, formoptions: { elmsuffix: ' *'} },
                { name: 'activo', index: 'activo', width: 100, align: 'left', editable: true, edittype: 'checkbox', editoptions: { value: "True:False" }, editrules: { required: false} },
                ],
        pager: $('#listPager'),
        rowNum: 20,
        rowList: [5, 10, 20],
        sortname: 'id',
        sortorder: "desc",
        viewrecords: true,
        imgpath: '/Content/ui-lightness/Images',
        width: "900",
        height: "400",
        ondblClickRow: function(rowid, iRow, iCol, e) {
            $("#list").editGridRow(rowid, prmGridDialog);
        }
    }).navGrid('#listPager',
            {
                edit: true, add: true, del: true, search: false, refresh: true
            },
            updateDialog,
            updateDialog,
            updateDialog
        );
});       
</script>

但是,只有使用fecha_inicio的日期选择器才能进行数据输入。

我已经阅读了几个网络示例,但找不到解决方案,我做错了什么?

1 个答案:

答案 0 :(得分:0)

显然

发生了失败
showOn: 'both'

当它改为

showOn: 'button'

正常工作