Я уже использую этот указатель даты в другом представлении, представлении Create (), которое получает модель, затем я могу показать средство выбора даты, используя:
<link rel="stylesheet"href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">
...
@Html.EditorFor(model => model.OrderDate, new { htmlAttributes = new { @class = "form-control", placeholder = "OrderDate", @readonly = "true" } })
...
@section Scripts
{
@Scripts.Render("~/bundles/jqueryui")
<script type="text/javascript">
jQuery.validator.methods["date"] = function (value, element) { return true; }
$(document).ready(function () {
$("#OrderDate").val("");
$('input[type=datetime]').datepicker({
dateFormat: 'dd/mm/yy',
changeMonth: true,
changeYear: true,
yearRange: "-1:+2",
onClose: function (dateText, inst) {
$("#cmdEnter").focus();
}
});
});
</script>
}
Теперь проблема в том, что мне нужно использовать указатель даты в представлении в качестве одного из полей поиска сверху, я пытаюсь реализовать поиск по диапазону.Это представление является индексом, то есть оно не получает модель, а получает коллекцию моделей (в данном случае PageList):
@model PagedList.IPagedList<EntregaMedicamentos.Models.PedidoDisprofarmaViewModel>
Итак, в этом случае я не могу использовать модель => модель.OrderDate, затем я попытался использовать Viewbag для передачи этой даты, что-то вроде ..
@Html.TextBox("searchDateFrom", ViewBag.currentFilter2 as DateTime?, new { @class = "form-control", placeholder = "Desde fecha", @readonly = "true" })
Так что я изменил с EditorFor на TextBox и также попытался с Editor, но средство выбора даты по-прежнему не хочет всплыватьна клик, есть идеи?
Это то, что попробовали, до сих пор нет всплывающих окон:
@Html.TextBox("searchDateFrom", ViewBag.currentFilter2 as DateTime?, new { @class = "form-control", placeholder = "Desde fecha", @readonly = "true" })
....
@section scripts
{
@Scripts.Render("~/bundles/jqueryval")
@Scripts.Render("~/bundles/jqueryui")
@Styles.Render("~/Content/cssjqryUi")
<script type="text/javascript">
jQuery.validator.methods["date"] = function (value, element) { return true; }
$(document).ready(function () {
$("#searchDateFrom").val("");
$('input[type=datetime]').datepicker({
dateFormat: 'dd/mm/yy',
changeMonth: true,
changeYear: true,
yearRange: "-1:+2",
onClose: function (dateText, inst) {
$("#cmdSearch").focus();
}
});
});
</script>
...
Спасибо !!