This question is locked. New answers and comments are not allowed.
hi all.i have a index view which has two partial view.one is PartialSearch which contain one textbox and two calenders for the search option of the grid.Another is PartialList where the grid reside.Suppose user select a date(lets say From Date) from calender and press search button the grid will populate those data which creation date is greater than or equal to From Date.If he clear the calender field,all data will populate(Compare with DateTime.MinValue actually) .i set filter on create date(actually on EntityTrackingInfoCreateDate).My problem is that when From Date is empty no data is populating(DataBinding method is not being called). When i select a data from calender,search data is populating correctly(DataBinding method is being called),but when i click Filter icon on Create Date field,it failed to expand and i get a javascript error in firebug which is date is not defined.what can i do.i think you understand my objective.Necessary code is given bellow.Please help me.
Index view:
PartialSearch PartialView:
PartialList Partial View:
My Controller actions:
Please help me..
Index view:
@model IEnumerable<ERPRealState.Models.CustomRolesVM>@{ ViewBag.Title = "Role List"; Layout = "~/Areas/Administrator/Views/Shared/_Layout.cshtml"; }<script src="@Url.Content("~/Scripts/CustomRole.js")" type="text/javascript"></script>@using (Ajax.BeginForm("Index", "CustomRole", new AjaxOptions{ HttpMethod = "get", InsertionMode = InsertionMode.Replace, OnBegin = "ListBeginLoading", OnSuccess = "ListSuccessLoading", OnComplete = "ListCompleteLoading", OnFailure = "ListFailureLoading", UpdateTargetId = "gridContainer"},new{ id = "frmCustomRoles", method = "get"})){ <div class="BoxHeader"> <div class="BoxHeaderContainer"> <div class="TitleBoxLeft"> <img src="@Url.Content("~/Images/arrow.gif")" alt=" " /> </div> <div class="TitleBoxMid"> Role List </div> </div> </div> <div class="MasterBoxContainer"> <div class="ChildBoxContainer"> <div style="clear: both"> </div> <div class="BoxContainer"> <div style="width: 98%; text-align: left"> <div id="SearchOption"> @Html.Partial("PartialSearch") </div> <div id="gridContainer"> @Html.Partial("PartialList") </div> </div> </div> </div> <img src="@Url.Content("~/Images/BoxRightTop.gif")" class="RightTopImage" alt=" " /> <img src="@Url.Content("~/Images/BoxLeftBottom.gif")" class="LeftBottomImage" alt=" " /> <img src="@Url.Content("~/Images/BoxRightBottom.gif")" class="RightBottomImage" alt=" " /> </div>}<div style="float: left; width: 100%"> <fieldset style="margin: 0px; padding-bottom: 5px"> <legend style="padding: 0px; margin: 0px; font-family: Tahoma; font-size: small; color: #4682B4">Search Option</legend> <div class="child-container" style="width: 220px; margin-top: 0px"> <div class="control-container" style="width: 70px"> @Html.Label("Role Name") </div> <div class="control-container" style="width: 10px"> @Html.Label(":") </div> <div class="control-container" style="width: 100px"> <input type="text" id="roleName" class="textbox-modifier" style="width: 100px" name="roleName" @*data-autocomplete="@Url.Action("QuickSearch","RestateProject")" *@ /> </div> </div> <div class="child-container" style="width: 200px; margin-top: 0px"> <div class="control-container" style="width: 70px"> @Html.Label("From Date") </div> <div class="control-container" style="width: 10px"> @Html.Label(":") </div> <div class="control-container" style="width: 100px"> @(Html.Telerik().DatePicker().InputHtmlAttributes(new Dictionary<string, object> { { "class", "textbox-modifier" }, { "style", "font-weight: normal;height:15px" } }).Name("fromDate")) </div> </div> <div class="child-container" style="width: 200px; margin-top: 0px"> <div class="control-container" style="width: 70px"> @Html.Label("To Date") </div> <div class="control-container" style="width: 10px"> @Html.Label(":") </div> <div class="control-container" style="width: 100px"> @(Html.Telerik().DatePicker().InputHtmlAttributes(new Dictionary<string, object> { { "class", "textbox-modifier" }, { "style", "font-weight: normal;height:15px" } }).Name("toDate")) </div> </div> </fieldset></div><div style="clear: both"> @*@Html.Hidden("hfID")*@</div><div style="border: 1px solid #F0F0F0; height: 33px; margin-top: 2px; width: 100%"> <div style="float: left; padding-left: 5px"> <a href="#" style="cursor: pointer" id="linkSearch"> <img src="@Url.Content("~/Images/Search.bmp")" alt="Search" style="border: none" /> </a> </div> <div style="float: right; padding: 5px 5px 0px 0px"> @Html.ActionLink("[ Add New ]", "Create", "CustomRole") </div></div><br />@model IEnumerable<ERPRealState.Models.CustomRolesVM>@(Html.Telerik().Grid(Model) .Name("Grid") .BindTo(Model) .EnableCustomBinding(true) .DataKeys(keys => keys.Add(c => c.CustomRoleId)) .DataBinding(dataBinding => { dataBinding.Ajax(). Select("CustomBinding", "CustomRole", new { roleName = ViewBag.RoleName, fromDate = ViewBag.FromDate, toDate = ViewBag.ToDate }). Delete("Delete", "CustomRole", new { roleName = ViewBag.RoleName, fromDate = ViewBag.FromDate, toDate = ViewBag.ToDate }); }) .Columns(columns => { columns.Command(commands => { commands.Delete().ButtonType(GridButtonType.BareImage).HtmlAttributes(new { id = "delete" }); commands.Custom("Edit").Ajax(false).Action("Edit", "CustomRole").SendDataKeys(true).ButtonType(GridButtonType.BareImage).HtmlAttributes(new { id = "edit" }); }).Width(200); columns.Bound(o => o.CustomRoleId).Visible(false); columns.Bound(o => o.Name).Title("Role Name"); columns.Bound(o => o.Description); columns.Bound(o => o.EntityTrackingInfoCreateDate).Title("Create Date").Format("{0:MM/dd/yyyy}"); }) .Pageable(settings => settings.Total((int)ViewBag.Total)) .EnableCustomBinding(true) .Sortable() .Filterable(filtering => filtering.Filters(filters => { filters.Add(o => o.EntityTrackingInfoCreateDate).IsGreaterThanOrEqualTo(ViewBag.FromDate == null ? DateTime.MinValue : ((DateTime)(ViewBag.FromDate))); })) .Groupable())namespace ERPRealState.Areas.Administrator.Controllers{ public class CustomRoleController : ApplicationController { ICustomRoleService service; public CustomRoleController(ICustomRoleService service) { this.service = service; } [HttpGet] [OutputCache(Duration = 0)] public ActionResult Index(string roleName,DateTime? fromDate,DateTime? toDate) { ViewBag.RoleName = roleName; ViewBag.FromDate = fromDate; ViewBag.ToDate = toDate; ViewBag.Total = 0; if (Request.IsAjaxRequest()) { ModelState.Clear(); return PartialView("PartialList"); } return View(); } [GridAction(EnableCustomBinding = true)] public ActionResult CustomBinding(string roleName, DateTime? fromDate, DateTime? toDate, GridCommand gridCommand) { ViewBag.RoleName = roleName; ViewBag.FromDate = fromDate; ViewBag.ToDate = toDate; int totalCount = 0; var data = service.Search(gridCommand, out totalCount); ViewBag.Total = totalCount; if (Request.IsAjaxRequest()) { ModelState.Clear(); return PartialView("PartialList", new GridModel { Data = data, Total = totalCount }); } return View("Index",data); } ....... .................. ....................