2013-04-11 45 views
1

我希望這很容易。我使用Google搜索並查看了論壇,但找不到確鑿的答案。一個答案是添加日曆js文件,但似乎沒有工作。日期格式不起作用 - Telerik電網詳情

看看下面突出顯示的代碼。前兩個格式定義爲空,不應該是。當我需要的是「MM/dd/yyyy」時,接下來的2個具有真正的長日期格式。哎呀!

<%= 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

+0

基思巴羅斯我不知道我明白你的問題正確顯示所需的日期格式無論如何,我們不想改變JS只是像這樣在網格列添加** c.Bound(e => e.OriginalPlannedDate ).Format(「{0:d}」)** – snowp 2013-04-12 12:10:49

+0

不是在網格列中 - 它在詳細信息模板中。 – 2013-04-12 22:16:01

回答

2

所以,我終於找到了如何在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(...)

+0

感謝您提醒我關於ClientTemplate。 – Suncat2000 2015-05-26 19:43:21