1

私のjqgridでは、EntryDateのポップアップ日付ピッカーが必要ですが、何が悪いのでしょうか

<script type="text/javascript"> 
    jQuery("#Countrylist").jqGrid({
        url: '/Country/GetAllCountries/',
        datatype: 'json',
        mtype: 'GET',
        colNames: ['EntryDate','EntryBy'],
        colModel: [
         {
             name: 'EntryDate', index: 'EntryDate', width: 90, editable: true,
             editoptions: {
                 dataInit: function (el)
                 { setTimeout(function () { $(el).datepicker(); }, 200); }
             }
         },
          { name: 'EntryBy', index: 'EntryBy', width: '200', align: 'center', editable: true, editable: true }

        ],
        editurl: "/Country/Edition",
        }); jQuery("#Countrylist").jqGrid('navGrid', '#Countrypager',
    { edit: true, add: true, del: true, search: false, refresh: true },
             {
                 closeOnEscape: true, reloadAfterSubmit: true,
                 closeAfterEdit: true, left: 450, top: 300, width: 520
             },
             { closeOnEscape: true, reloadAfterSubmit: true, left: 450, top: 300, url: "/Country/Deletion", mtype: "POST" },
            { closeOnEscape: true, reloadAfterSubmit: true, left: 450, top: 300 });
  });
    </script>

私のレイアウトページには、次の参照があります

<link href="~/Scripts/jquery.jqGrid-4.5.2/css/ui.jqgrid.css" rel="stylesheet" />
        <link href="~/Scripts/pepper-grinder/jquery.ui.theme.css" rel="stylesheet" />
        <script src="~/jquery-ui-1.9.2.custom/js/jquery-1.8.3.js"></script>
        <script src="~/jquery-ui-1.9.2.custom/js/jquery-ui-1.9.2.custom.min.js"></script>
        <script src="~/jquery-ui-1.9.2.custom/development-bundle/ui/jquery.ui.datepicker.js"></script>
        <script src="~/Scripts/jquery.jqGrid-4.5.2/src/jquery.jqGrid.js"></script>
        <script src="~/Scripts/jquery.jqGrid-4.5.2/src/i18n/grid.locale-en.js"></script>
        <script src="~/Scripts/jquery.jqGrid-4.5.2/src/jquery.jqGrid.js"></script>
        <script src="~/Scripts/jquery.jqGrid-4.5.2/src/jqModal.js"></script>
        <script src="~/Scripts/jquery.jqGrid-4.5.2/src/jqDnR.js"></script>

firebug は次のエラーを示します

$(...).datepicker は関数ではありません

しかし、datepicker が firebugs net タブで正常に読み込まれていることがわかります

4

3 に答える 3

2

この場合、プラグインを初期化するまで、すべてがロードされるまで待つ必要があります

$(function () {
   jQuery("#Countrylist").jqGrid({ 
        url: '/Country/GetAllCountries/',
        datatype: 'json',
        mtype: 'GET',
        colNames: ['EntryDate','EntryBy'],
        colModel: [
         {
             name: 'EntryDate', index: 'EntryDate', width: 90, editable: true,
             editoptions: {
                 dataInit: function (el)
                 { setTimeout(function () { $(el).datepicker(); }, 200); }
             }
         },
          { name: 'EntryBy', index: 'EntryBy', width: '200', align: 'center', editable: true, editable: true }

        ],
        editurl: "/Country/Edition",
        }); jQuery("#Countrylist").jqGrid('navGrid', '#Countrypager',
        { edit: true, add: true, del: true, search: false, refresh: true },
             {
                 closeOnEscape: true, reloadAfterSubmit: true,
                 closeAfterEdit: true, left: 450, top: 300, width: 520
             },
             { closeOnEscape: true, reloadAfterSubmit: true, left: 450, top: 300, url: "/Country/Deletion", mtype: "POST" },
            { closeOnEscape: true, reloadAfterSubmit: true, left: 450, top: 300 });
   });
});

編集: http://api.jquery.com/ready/で詳細情報を取得できます

于 2013-08-22T11:59:55.397 に答える
0

私はちょうど削除しました

@Scripts.Render("~/bundles/jquery")

私のlayout.cshmlから今

$(function () {
        jQuery("#Countrylist").jqGrid({**mycode**})}); 

@TheCodeDestroyerが言ったように..今は動いている

于 2013-08-22T12:15:26.440 に答える
0

私は過去に彼をやった http://jsfiddle.net/Yenros/bbPeP/

すみません...このコンポーネントをしばらく使用していませんが、コードはまだ関連しているはずです

   initDateEdit = function (elem) {
            setTimeout(function () {
                $(elem).datepicker({
                    dateFormat: 'dd-M-yy',
                    ...
                });
            }, 100);
        };

それからあなたのcolモデルで

{ name: 'Week_Start', formatter: 'date', formatoptions: { newformat: 'd-M-Y' }, datefmt: 'd-M-Y', editoptions: { dataInit: initDateEdit }, searchoptions: { dataInit: initDateSearch } }
于 2013-08-22T12:08:18.067 に答える