Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
949 views
in Technique[技术] by (71.8m points)

asp.net mvc - Date filter not working in gridmvc

I am developing Mvc application. I used gridMvc version 2.0.0.0. when I am trying to filter date but it not working.When i am trying to select date from calender,date is not getting selected.

below is my code for view

@model IEnumerable<StockWatch.DTO.EmployeeDTO>
@using GridMvc.Html
@using System.Web.UI.WebControls

@{
    ViewBag.Title = "Index";
}
<div class="row-fluid" style="margin-top:30px;margin-bottom:10px;margin-left:0px; margin-right:0px;">
    <div class="listheading span9">
        <div class="span2" style="font-size:22px;margin-right:5px;">
            Employees
        </div> 
    </div>
    <div class="createlink span3" style="text-align:right;margin-left:10px;">
        @Html.ActionLink("+ Add Employee", "Create")
    </div>
</div>

<div class="span12" style="margin-left:0px;margin-right:0px;">
        @Html.Grid(Model).Columns(columns => 
                    {
                        columns.Add(c => c.FirstName).Titled("First Name").SetWidth(400).Sortable(true).Filterable(true);
                        columns.Add(c => c.LastName).Titled("Last Name").SetWidth(900).Sortable(true).Filterable(true);
                        columns.Add(c => c.MobileNo).Titled("Mobile No.").SetWidth(400).Sortable(true).Filterable(true);
                        columns.Add(c => c.Email).Titled("Email").SetWidth(400).Sortable(true).Filterable(true);
                        columns.Add(c => c.LocationName).Titled("Location").SetWidth(800).Sortable(true).Filterable(true);
                        columns.Add(c => c.Designation).Titled("Designation").SetWidth(400).Sortable(true).Filterable(true);
                        columns.Add(c => c.JoiningDate).Titled("Joining<br/>Date").Format("{0:dd-MMM-yy}").SetWidth(400).Sortable(true).Filterable(true);  

</div>

How to do that? Thank you in advance.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You need to add script and styles for it.

And your field datatype must be Datetime.

Scripts and style for Grid.MVC

<link href="@Url.Content("~/Content/Gridmvc.css")" rel="stylesheet" />
<link href="@Url.Content("~/Content/bootstrap.min.css")" rel="stylesheet" />
<script src="@Url.Content("~/Scripts/jquery-1.9.1.min.js")"></script>
<script src="@Url.Content("~/Scripts/gridmvc.min.js")"></script>

Scripts and style for Grid.Mvc datepicker

<script src="~/Scripts/bootstrap-datepicker.js"></script>
<link href="~/Content/gridmvc.datepicker.css" rel="stylesheet" />
<link href="~/Content/gridmvc.datepicker.min.css" rel="stylesheet" />

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...