日期格式不工作- teleerik网格细节



我希望这很容易。我谷歌和通过论坛看,不能找到一个坚实的答案。一个解决方案是添加日历js文件,但这似乎不起作用。

请看下面高亮显示的代码。定义了格式的前两个是空白的,不应该是。接下来的两个有很长的日期格式,而我需要的只是"MM/dd/yyyy"。呵!

<%= Html.Telerik().Grid<ViewModelProcurementAction>(Model.ProcurementActions) // 
        .Name("ProcurementActionGrid")
            .DetailView(details => details.ClientTemplate(
                Html.Telerik()
                    .TabStrip()
                    .Name("TabStrip_<#= Id #>")
                    .SelectedIndex(0)
                    .Items(items =>
                        {
                            items.Add().Text("Additional Info").Content(
                                "<table>" +
                                    "<tr>" +
                                        "<td style='vertical-align: top'>" +
                                            "<b>Summary Description:</b><br/><#= SummaryDescription #>" +
                                        "</td>" +
                                        "<td style='vertical-align: top'>" +
                                            //"<ul>" +
                                            "<b>Modification Number:</b> <#= ModificationNumber #><br/>" +
                                            "<b>Funding Type:</b> <#= FundingTypeName #><br/>" +
                                            "<b>Department Name:</b> <#= DepartmentName #><br/>" +
                                            "<b>Solicitation Type:</b> <#= SolicitationTypeName #><br/>" +
                                            "<b>Date Entered:</b> <#= $.telerik.formatString('{0:d}', DateEntered) #><br/>" +
                                            //"</ul>" +
                                        "</td>" +
                                        "<td style='vertical-align: top'>" +
                                            "<b>FY12:</b> <#= $.telerik.formatString('{0:c0}', FyByKey["FY12"]==null ? 0 : FyByKey["FY12"]) #><br/>" +
                                            "<b>FY13: </b><#= $.telerik.formatString('{0:c0}', FyByKey["FY13"]==null ? 0 : FyByKey["FY13"]) #><br/>" +
                                            "<b>FY14: </b><#= $.telerik.formatString('{0:c0}', FyByKey["FY14"]==null ? 0 : FyByKey["FY14"]) #><br/>" +
                                            "<b>FY15: </b><#= $.telerik.formatString('{0:c0}', FyByKey["FY15"]==null ? 0 : FyByKey["FY15"]) #><br/>" +
                                            "<b>FY16: </b><#= $.telerik.formatString('{0:c0}', FyByKey["FY16"]==null ? 0 : FyByKey["FY16"]) #><br/>" +
                                            "<b>FY17: </b><#= $.telerik.formatString('{0:c0}', FyByKey["FY17"]==null ? 0 : FyByKey["FY17"]) #><br/>" +
                                            "<b>Out Year Funding: </b><#= $.telerik.formatString('{0:c0}', OutYearFunding==null ? 0 : OutYearFunding ) #><br/>" +
                                        "</td>" +
                                        "<td style='vertical-align: top'>" +
                                            "<b>DBE %: </b><#= $.telerik.formatString('{0:0}', DBE==null ? 0 : DBE) #><br/>" +
                                            "<b>Amount Exceeds: </b><#= AmountExceeds #><br/>" +
//--------------------------------------------------------------------------------
                                            "<b>Cost/Price Analysis Date: </b><#= $.telerik.formatString('{0:MM/dd/yyyy}', CostPriceAnalysisDate==null ? '' : CostPriceAnalysisDate) #><br/>" +
                                            "<b>OIG Review Completion Date: </b><#= $.telerik.formatString('{0:shortDate}', OIGReviewCompletionDate==null ? '' : OIGReviewCompletionDate) #><br/>" +
                                            "<b>Required Procurement Initiation Date: </b><#= RequiredProcurementInitiationDate #><br/>" +
                                            "<b>Required Date of Award: </b><#= RequiredDateOfAward #><br/>" +
//--------------------------------------------------------------------------------
                                            "<b>Number of Option Years: </b><#= NumberOfOptionYears #><br/>" +
                                            "<b>Budget Approval: </b><#= BudgetApproval #><br/>" +
                                            "<b>Point of Contact: </b><#= PointOfContact #><br/>" +
                                        "</td>" +
                                        "<td style='vertical-align: top'>" +
                                            "<b>PRMT Group: </b><#= PRMTGroupName #><br/>" +
                                            "<b>Planned CA Responsible: </b><#= PlannedCAResponsibleFullName #><br/>" +
                                            "<b>Value of Option Years: </b><#= $.telerik.formatString('{0:0}', ValueOfOptionYears==null ? 0 : ValueOfOptionYears) #><br/>" +
                                            "<b>Award Amount: </b><#= $.telerik.formatString('{0:0}', AwardAmount==null ? 0 : AwardAmount) #><br/>" +
                                            "<b>Awarded Vendor: </b><#= AwardedVendor #><br/>" +
                                            "<b>Multiple Year Funding: </b><#= MultipleYearFunding #><br/>" +
                                            "<b>Period of Performance: </b><#= $.telerik.formatString('{0}{1}{2}', PeriodOfPerformanceStartDate==null ? '' : PeriodOfPerformanceStartDate, PeriodOfPerformanceEndDate==null ? '' : ' - ', PeriodOfPerformanceEndDate==null ? '' : PeriodOfPerformanceEndDate) #><br/>" +
                                            "<b>Comments: </b><#= Comments #><br/>" +
                                        "</td>" +
                                    "</tr>" +
                                "</table>"
                                );
                            items.Add().Text("Purchase of Materials").Content(
                                "<br/><input type='checkbox' disabled='disabled' name='AwaitingProcurementPackEnabled' <#= AwaitingProcurementPackEnabled ? checked='checked' : '' #> /> <b>Awaiting Procurement pack from Point of Contact</b><br/>" +
                                Html.Telerik()
                                    .Grid<ViewModelProcurementActivity>()
                                    .Name("ActionGrid_<#= Id #>")
                                    .Footer(false)
                                    .Columns(c =>
                                        {
                                            c.Command(commands =>
                                            {
                                                commands.Edit().ButtonType(GridButtonType.ImageAndText);
                                            }).Title("Actions").Width(120);
                                            c.Bound(e => e.ActivityId).Visible(false);
                                            c.Bound(e => e.Activity);
                                            c.Bound(e => e.OriginalPlannedDate);
                                            c.Bound(e => e.CurrentPlannedDate);
                                            c.Bound(e => e.ActualDate);
                                            c.Bound(e => e.ReasonForDateChange);
                                        })
                                    .DataBinding(dataBinding =>
                                        dataBinding.Ajax()
                                        .Select("AjaxGetActionDatesFor", "ProcurementActions", new { procurementActionId = "<#= Id #>" })
                                        .Update("AjaxUpdateActionDatesFor", "ProcurementActions")
                                        .Enabled(true)
                                        )
                                    .DataKeys(keys => keys.Add(c => c.ActivityId))
                                    .Editable(editing => editing.Mode(GridEditMode.InLine)
                                    )
                                    .Selectable()
                                    .ToHtmlString()
                                );
                        })
                    .ToHtmlString()
            ))
        .Columns(c =>
            {
                c.Command(commands =>
                    {
                        commands.Edit().ButtonType(GridButtonType.ImageAndText);
                        commands.Delete().ButtonType(GridButtonType.ImageAndText);
                        commands.Custom("showHistory")
                                .ButtonType(GridButtonType.ImageAndText)
                                .Text("History")
                                .Action("Show", "ProcurementActions")
                                .DataRouteValues(route => { route.Add(o => o.Id).RouteKey("id"); });
                    }).Title("Actions").Width(100);
                c.Bound(e => e.Id).Visible(false);
                c.Bound(e => e.ActionId).Visible(false);
                c.Bound(e => e.ContractNumber).HtmlAttributes(new {style = "vertical-align: top"});
                c.Bound(e => e.ContractManager).Width(120).HtmlAttributes(new {style = "vertical-align: top"});
                c.Bound(e => e.ActualCAResponsible).Width(150).HtmlAttributes(new {style = "vertical-align: top"});
                c.Bound(e => e.TitleOfRequirement).HtmlAttributes(new {style = "vertical-align: top"});
                c.Bound(e => e.CipOrName).Title("Project Id").HtmlAttributes(new {style = "vertical-align: top"});
                c.Bound(e => e.RecordTypeName).Title("Record Type").HtmlAttributes(new {style = "vertical-align: top"});
                c.Bound(e => e.FullContractType).Title("Contract Type").HtmlAttributes(new { style = "vertical-align: top" });
                c.Bound(e => e.ProcurementActionYearDisplayName).Title("Plan FY").HtmlAttributes(new { style = "vertical-align: top" });
            })
        .DataKeys(keys => keys.Add(o => o.Id))
        .DataBinding(dataBinding =>
                     dataBinding.Ajax()
                       .OperationMode(GridOperationMode.Client)
                       .Select("AjaxGetAll", "ProcurementActions") //, new { procurementActionId = "<#= CurrentAction #>" })
                       .Update("AjaxUpdate", "ProcurementActions")
                       .Delete("AjaxDelete", "ProcurementActions")
                       .Enabled(true)
        )
        .Editable(editing => 
            editing.Mode(GridEditMode.PopUp)
                   .TemplateName("EditProcurementAction")
                   //? .AdditionalViewData(new { ListAllProcurementActionDateTypes = Model.AllProcurementActionDateTypes })
                   //? .AdditionalViewData(Model.AllUsers)
                   //? .AdditionalViewData(Model.ContractTypes)
                   //? .AdditionalViewData(Model.FundingTypes)
            )
        .Pageable(paging => paging.PageSize(15))
        .Scrollable(scrolling => scrolling.Height(500))
        .Filterable()
        .Sortable()
%>    

At the end of my file I changed this:
<%= Html.Telerik().ScriptRegistrar() %>
To this:
<%= Html.Telerik()
        .ScriptRegistrar() 
        .DefaultGroup(group => group.Add("telerik.common.js")
                                    .Add("telerik.calendar.js")
                                    .Add("telerik.datepicker.js")
                                    .Add("telerik.textbox.js"))
%>

仍然什么都没有。

我正试图今天(最后一次)交付这篇文章,但由于格式问题,我受到了批评。

任何想法吗?

kb

所以我终于找到了如何在ClientTemplate中正确地做到这一点:

"<b>Cost/Price Analysis Date: </b><#= $.telerik.formatString('{0:MM/dd/yyyy}', CostPriceAnalysisDate==null ? "" : CostPriceAnalysisDate) #><br/>" +
"<b>OIG Review Completion Date: </b><#= $.telerik.formatString('{0:MM/dd/yyyy}', OIGReviewCompletionDate==null ? "" : OIGReviewCompletionDate) #><br/>" +
"<b>Required Procurement Initiation Date: </b><#= $.telerik.formatString('{0:MM/dd/yyyy}', RequiredProcurementInitiationDate==null ? "" : RequiredProcurementInitiationDate) #><br/>" +
"<b>Required Date of Award: </b><#= $.telerik.formatString('{0:MM/dd/yyyy}', RequiredDateOfAward==null ? "" : RequiredDateOfAward) #><br/>" +

需要调用$.telerik.formatString(…)

最新更新