1

我有一個視圖(請參閱下面的代碼),但datetimepicker正在拉伸,現在去除拉伸。可能是由於引導表。需要一些指導以優雅的方式顯示datetimepicker。MVC datetimepicker拉伸

enter image description here

<div class="container"> 
     <div class="clearfix"></div> 
     @using (Html.BeginForm("Create", "DoctorPayment")) 
     { 
      @Html.AntiForgeryToken() 
      @Html.ValidationSummary(true) 

     <fieldset> 
      @*<legend>DoctorPayment</legend>*@ 
      <div class="panel"> 
       <div class="panel-body"> 
        ... 
        <div class="row"> 
         <div class="col-lg-3 pull-left"> 
          <div class="editor-label"> 
           @Html.LabelFor(model => model.PaymentDate) 
          </div> 
         </div> 
         <div class="col-lg-9"> 
          <div class="editor-field"> 
           @Html.EditorFor(model => model.PaymentDate) 
           @Html.ValidationMessageFor(model => model.PaymentDate) 
          </div> 
         </div> 
         <div class="col-lg-1"> 

         </div> 
        </div> 
        <div style="margin-top: 5px"></div> 
        .... 
       </div> 
       <p> 
        <input type="submit" value="Create" /> 
       </p> 
      </div> 
     </fieldset> 
     } 
     <div> 
      @Html.ActionLink("Back to List", "Index") 
     </div> 
     .... 

     @section Scripts { 
    @Scripts.Render("~/bundles/jqueryval") 
    @Styles.Render("~/Content/boostrap") 
    @Scripts.Render("~/bundles/jqueryui") 
    @Styles.Render("~/Content/cssjqryUi") 

<script type="text/javascript"> 
    $(document).ready(function() { 
     $('input[type=datetime]').datepicker({ 
      dateFormat: "dd/M/yy", 
      changeMonth: true, 
      changeYear: true, 
      yearRange: "-60:+0" 
     }); 

    }); 

    $('#PaymentDate').datepicker({ 
     showButtonPanel: false, 

     beforeShow: function() { 
      $(".ui-datepicker").css('font-size', 12) 
     } 
    }); 

    $("#PaymentDate").click(function() { 
     $("#ui-datepicker-div") 
      // BTW, min-width is better: 
      .css("min-width", $(this).outerWidth() + "px"); 

    }); 
</script> 

} 
     } 
    </div> 

我已經包括引導它。

回答

2

我相信你可能已經在css中覆蓋了某些東西,或者添加了一些屬性。

試試看看它是否有效。

$("#dropdown").closest("span.k-dropdown").width(400); 

如果是這樣,請嘗試將自定義類添加到datepicker,以便不編輯所有下拉列表。

此外,更改字體大小將更改日期選擇器的大小。

$('#PaymentDate').datepicker({ 
    showButtonPanel: false, 
    beforeShow: function() { 
     $(".ui-datepicker").css('font-size', 12) 
    } 
}); 

$("#PaymentDate").click(function() { 
    $("#ui-datepicker-div") 
     .css("max-width", $(this).outerWidth() + "px"); 
}); 
+0

我已更新原始代碼,有沒有進一步的改進,我可以申請? – Sanjeewa

+0

如果datepicker看起來不錯,那麼這個問題就解決了。如果在多個頁面上有多個日期選擇器,另一個常用的方法是將腳本放在「共享」視圖的「_Layout」視圖中(如果有),因爲它不會延長加載時間。 –

+0

,不,它沒有那麼好,使字體大小爲12有所改善,任何人都可以檢查我的「@section腳本」部分,.css(「min-width」,$(this).outerWidth()+ 「px」)我不確定最小寬度是否正確應用 – Sanjeewa