This is a migrated thread and some comments may be shown as answers.

[Solved] How to show calendar for grid input as per documentation

1 Answer 95 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
steve
Top achievements
Rank 1
steve asked on 07 Dec 2011, 09:25 AM
Hi:

How do I get the calendar input editor that is shown in the documentation at:

http://www.telerik.com/help/aspnet-mvc/telerik-ui-components-grid-editing-cell-editing-and-batch-updates.html

my grid displays just fine except for editing the Date fields.  And when I go to edit the date field i just get textbox and ... the grid resets it to 1969/12/31 on focus leaving the textbox.

This is my view:  (ScriptRegister and StyleSheetRegister are in the master page)

thx

<%@ Page   MasterPageFile="~/MasterPages/ViewSingle.Master"  Language="C#" Inherits="System.Web.Mvc.ViewPage<IEnumerable<eDrinx.Areas.Classes.LTOPRODUCT>>" %>
 
 <asp:Content ContentPlaceHolderID="MainContent" runat="server">
    <%
        Html.Telerik().Grid(Model)
        .Name("LtoProducts")
        .DataKeys(keys => keys.Add(c => c.PRODUCTID))
        .ToolBar(commands =>
        {
            commands.Insert();
            commands.SubmitChanges();
        })
        .DataBinding(dataBinding => dataBinding.Ajax()
                     .Select("SelectData","LTOPRODUCTSGRID")
            //Action method
                     .Update("Update", "LTOPRODUCTSGRID"))
 
         .Editable(editing => editing.Mode(GridEditMode.InCell))
         .Columns(columns =>
                {
                    columns.Add(c => c.IDVALUE).Width(50).ReadOnly().Title("ID").HtmlAttributes(new { @class = "detailLine" });
                    columns.Add(c => c.PRODUCTNAME).Width(200).ReadOnly().Title("Name").HtmlAttributes(new { @class = "detailLine" });
                    columns.Add(c => c.LTOSTARTDATE).Width(100).Format("{0:yyyy-MM-dd}").Title("Lto Start").HtmlAttributes(new { @class = "detailLine" });
                    columns.Add(c => c.LTOENDDATE).Width(100).Format("{0:yyyy-MM-dd}").Title("Lto End").HtmlAttributes(new { @class = "detailLine" });
                    columns.Add(c => c.PACKAGETYPEDESC).Width(100).ReadOnly().Title("Package Type").HtmlAttributes(new { @class = "detailLine" });
                    columns.Add(c => c.LATESTCHARGEVALUE).Width(100).ReadOnly().Title("Current Price").Format("{0:$0.00}").HtmlAttributes(new { @class = "detailLine", @style = "text-align: right" });
                    columns.Add(c => c.BLTOFLAG).Width(50).Title("Lto Display").HtmlAttributes(new { @class = "detailLine"});
                }
                 )
            .Pageable(paging =>
                           paging.PageSize(10)
                                 .Style(GridPagerStyles.NextPreviousAndNumeric)
                                 .Position(GridPagerPosition.Bottom)
                )
        .Sortable()
        .Render();
    %>
     <asp:HyperLink ID="HyperLink1"   Style="color:Blue"  NavigateUrl="~/suppliers/products/default.aspx" runat="server">Go Back >></asp:HyperLink>
     </asp:Content>

1 Answer, 1 is accepted

Sort by
0
steve
Top achievements
Rank 1
answered on 14 Dec 2011, 07:17 AM
Ok ... after much chasing through the documentation I determined that it is necessary to put "[DataType(DataType.Date)]" on the model relevant model property.   Wasn't obvious to me as documentation is not that great.

cheers
Tags
Grid
Asked by
steve
Top achievements
Rank 1
Answers by
steve
Top achievements
Rank 1
Share this question
or