Int bound grid column not showing numeric text editor

11 posts, 0 answers
  1. Matt
    Matt avatar
    1 posts
    Member since:
    Jul 2012

    Posted 01 Jun 2012 Link to this post

    I'm playing around with the new MVC wrappers and I'm having trouble with the grid editors in the examples.
    When I view the InlineEditing sample for the grid, clicking the Create button on the toolbar provides an inline editor with numeric text boxes.
    In my own project, the grid just shows standard textboxes. To try and see where I've gone wrong I've copied the code from the examples into a standalone project and that reproduces the error, showing only standard text boxes as well. No errors, just no numeric textbox.

    Any ideas where I could be going wrong?
  2. Dominic
    Dominic avatar
    15 posts
    Member since:
    Feb 2012

    Posted 01 Jun 2012 Link to this post

    Do you have an UIHint attribute on this property?

    [UIHint("Integer")]
    public Int32 MyProperty { get; set; }

    Do you have the EditorTemplates in your project?

    Regards
  3. Matt
    Matt avatar
    1 posts
    Member since:
    Jul 2012

    Posted 01 Jun 2012 Link to this post

    That was it, thanks Dominic!
  4. Jason
    Jason avatar
    4 posts
    Member since:
    Apr 2013

    Posted 17 Apr 2013 Link to this post

    I have decorated my property with [UIHint("Integer")] and the grid still does not render a numeric textbox in the grid.  If I change the property from int? to double? the numeric textbox appears
  5. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 18 Apr 2013 Link to this post

    Hi,

    You can find more info here: http://docs.kendoui.com/getting-started/using-kendo-with/aspnet-mvc/helpers/grid/faq#how-do-i-use-kendo-widgets-as-editors-for-dates-and-numbers?

    Greetings,
    Atanas Korchev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  6. Jason
    Jason avatar
    4 posts
    Member since:
    Apr 2013

    Posted 18 Apr 2013 Link to this post

    Atanas,

    Thank you I have reviewed all your pages that have reference to the custom editors and as they work for most of the other data types and for UIHints they do not however work for the (int?) inside the grid inline editing.  Can you please help since I use this throughout my application?

    Thank you,

    Jason
  7. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 18 Apr 2013 Link to this post

    Hi,

     Can you confirm that you have done the following (quote from the documentation link):

    To use those editor templates in your application copy all files from the corresponding folder ("ascx" or "razor") to ~/Views/Shared/EditorTemplates (you may need to create that folder if it does not exist).

    Those default editor templates are shipped in the \wrappers\aspnetmvc\EditorTemplates folder of the Kendo UI Complete for ASP.NET MVC installation.

    Regards,
    Atanas Korchev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  8. Jason
    Jason avatar
    4 posts
    Member since:
    Apr 2013

    Posted 18 Apr 2013 Link to this post

    Yes the editors are in the proper folders.  This is why they all work except for the Integer Editor in the inline grid editing.  I have even made a custom one that mimics the original you supplied but it still doesn't grab that one for the (int?) scenario.  All others appear to be working fine.
  9. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 18 Apr 2013 Link to this post

    Hi,

     Then we need to look at your model and grid declaration. Can you paste those here?

    All the best,
    Atanas Korchev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  10. Jason
    Jason avatar
    4 posts
    Member since:
    Apr 2013

    Posted 18 Apr 2013 Link to this post

    public class DailyDrillingTimeLog
    {
    public int DailyDrillingTimeLogId { get; set; }
    public int? DailyDrillingReportId { get; set; }

    [Display(Name = "Start Time")]
    [DataType(DataType.Time)]
    public DateTime? StartTime { get; set; }

    [Display(Name = "End Time")]
    [DataType(DataType.Time)]
    public DateTime? EndTime { get; set; }

    [Display(Name = "Duration")]
    public double? Duration { get; set; }

    [Display(Name = "Acct Code")]
    public int? Code2 { get; set; }

    [Display(Name = "Start Depth")]
    public int? StartDepth { get; set; }

    [Display(Name = "End Depth")]
    [UIHint("Integer")] //This does not work with the kendo ui inline editing
    public int? EndDepth { get; set; }

    [Display(Name = "P or TT")]
    [StringLength(3, ErrorMessage = "P or TT cannot exceed 3 characters.")]
    public string PorTt { get; set; }

    [Display(Name = "Comments")]
    [StringLength(1000, ErrorMessage = "Comments cannot exceed 1000 characters.")]
    public string Com { get; set; }

    public string Username { get; set; }
    public string LastUpdateBy { get; set; }
    public DateTime? LastUpdateDatetime { get; set; }

    public virtual DailyDrillingReport DailyDrillingReport { get; set; }

    [UIHint("DailyDrillingTimeCodeEditor")] //This works with the kendo ui inline editing
    public virtual DailyDrillingTimeCode DailyDrillingTimeCode { get; set; }
    }
    @{
    Html.Kendo().Grid<DailyDrillingTimeLog>()
    .Name("TimeLogGrid").HtmlAttributes(new {style = "width: 100%;"})
    .Columns(columns =>
    {
    columns.Command(command =>
    {
    command.Edit();
    command.Destroy();
    }).Width(172);
    columns.Bound(p => p.DailyDrillingReportId).Title("ID").Width(30);
    columns.Bound(p => p.StartTime).Title("Start Time");
    columns.Bound(p => p.EndTime).Title("End Time");
    columns.Bound(p => p.Duration).Title("Duration");
    columns.Bound(p => p.DailyDrillingTimeCode).Title("Code").ClientTemplate("#=DailyDrillingTimeCode.Desc#");
    columns.Bound(p => p.StartDepth).Title("Start Depth").Format("{0:n0}").EditorTemplateName("Integer");
    columns.Bound(p => p.EndDepth).Title("End Depth");
    columns.ForeignKey(p => p.PorTt, (IEnumerable) ViewData["PorTTs"], "Value", "Text").EditorTemplateName("PorTTEditor");
    columns.Bound(p => p.Com).Title("Comment");
    })
    .ToolBar(toolbar => toolbar.Create())
    .Editable(editable => editable.Mode(GridEditMode.InLine))
    .Pageable()
    .Sortable()
    .Scrollable()
    //.Events(events => events.DataBound("timeLogGridDataBound"))
    .DataSource(dataSource => dataSource
    .Ajax().PageSize(5)
    .Events(events => events.Error("error_handler"))
    .Read(read => read.Action("_TimeLog_Read", "Drilling", new {reportId = ViewData["DailyDrillingReportId"]}))
    .Create(update => update.Action("_TimeLog_Create", "Drilling"))
    .Model(m =>
    {
    m.Id(p => p.DailyDrillingTimeLogId);
    m.Field(p => p.DailyDrillingReportId).Editable(false).DefaultValue(ViewData["DailyDrillingReportId"] as int?);
    m.Field(p => p.DailyDrillingTimeCode).DefaultValue(null);
    m.Field(p => p.StartTime).DefaultValue(null);
    m.Field(p => p.EndTime).DefaultValue(null);
    m.Field(p => p.StartDepth).DefaultValue(null);
    m.Field(p => p.PorTt).DefaultValue(string.Empty);
    })
    .Update(update => update.Action("_TimeLog_Update", "Drilling"))
    .Destroy(update => update.Action("_TimeLog_Destroy", "Drilling"))

    ).Render();
    }
  11. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 19 Apr 2013 Link to this post

    Hi Jason,

     I tried to recreate the problem to no avail. Find attached my test project. It displays the numerictextbox editor for the EndDepth property. What is different in your case?

    Greetings,
    Atanas Korchev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top