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

Int bound grid column not showing numeric text editor

10 Answers 710 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Matt
Top achievements
Rank 1
Matt asked on 01 Jun 2012, 12:44 PM
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?

10 Answers, 1 is accepted

Sort by
0
Dominic
Top achievements
Rank 1
answered on 01 Jun 2012, 02:31 PM
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
0
Matt
Top achievements
Rank 1
answered on 01 Jun 2012, 03:35 PM
That was it, thanks Dominic!
0
Jason
Top achievements
Rank 1
answered on 17 Apr 2013, 06:53 PM
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
0
Atanas Korchev
Telerik team
answered on 18 Apr 2013, 12:31 PM
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!
0
Jason
Top achievements
Rank 1
answered on 18 Apr 2013, 01:45 PM
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
0
Atanas Korchev
Telerik team
answered on 18 Apr 2013, 01:49 PM
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!
0
Jason
Top achievements
Rank 1
answered on 18 Apr 2013, 03:26 PM
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.
0
Atanas Korchev
Telerik team
answered on 18 Apr 2013, 03:34 PM
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!
0
Jason
Top achievements
Rank 1
answered on 18 Apr 2013, 03:37 PM
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();
}
0
Atanas Korchev
Telerik team
answered on 19 Apr 2013, 08:21 AM
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!
Tags
Grid
Asked by
Matt
Top achievements
Rank 1
Answers by
Dominic
Top achievements
Rank 1
Matt
Top achievements
Rank 1
Jason
Top achievements
Rank 1
Atanas Korchev
Telerik team
Share this question
or