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?
10 Answers, 1 is accepted
[UIHint(
"Integer"
)]
public
Int32 MyProperty {
get
;
set
; }
Do you have the EditorTemplates in your project?
Regards
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
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
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.
Atanas Korchev
the Telerik team
Then we need to look at your model and grid declaration. Can you paste those here?
All the best,Atanas Korchev
the Telerik team
{
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();
}
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