This question is locked. New answers and comments are not allowed.
When I add a [DataType(DataType.Currency)] annotation to a field on my view model, when I click the edit button in the grid I am getting the following error in the telerik.textbox.min.js file:
Microsoft JScript runtime error: Unable to get value of the property 'toLowerCase': object is null or undefined
Here is the offending line of code:
if(k.nodeName.toLowerCase()!=="input"&&k.type.toLowerCase()!=="text"because k.type is undefined
Here is my grid:
@(Html.Telerik().Grid(Model) .Name( "Grid" ) .DataKeys( keys => keys.Add( s => s.AlbumId ) ) .ToolBar( commands => commands.Insert().ButtonType( GridButtonType.Image ).ImageHtmlAttributes( new { style = "margin-left:0" } ) ) .DataBinding( dataBinding => dataBinding.Ajax() .Select( "AjaxIndex", "StoreManager" ) .Insert( "Create", "StoreManager" ) .Update( "AjaxEdit", "StoreManager" ) .Delete( "Delete", "StoreManager" ) ) .Columns( columns => { columns.Bound( album => album.AlbumId ).Hidden( true ).ReadOnly( true ); columns.Bound( album => album.Genre ).Width( 75 ); columns.Bound( album => album.Artist ); columns.Bound( album => album.Title ); columns.Bound( album => album.Price ).Width( 75 ); columns.Command( commands => { commands.Custom( "viewDetails" ).Text( "Album Details" ).DataRouteValues( route => route.Add( s => s.AlbumId ).RouteKey( "AlbumId" ) ).Ajax( true ).Action( "ViewDetailsAjax", "StoreManager" ); commands.Edit().ButtonType( GridButtonType.Image ); } ).Width( 200 ).Title( "Commands" ); }) .PrefixUrlParameters( false ) .Scrollable( scrolling => scrolling.Enabled( true ) ) .Sortable( sorting => sorting.Enabled( true ) ) .Pageable( paging => paging.Enabled( true ) ) .Pageable( paging => paging.PageSize( 20 )) .Filterable( filtering => filtering.Enabled( true ) ) .Groupable( grouping => grouping.Enabled( true ) ) .Footer( true ) .Selectable() .ClientEvents( events => events.OnRowSelect( "onRowSelected" ) ) .ClientEvents( events => events.OnComplete( "onComplete" ) ) .Editable( editing => editing.Mode( GridEditMode.PopUp ) ) .TableHtmlAttributes( new { style = "table-layout:fixed;" } ) )
and here is the model:
using System.ComponentModel.DataAnnotations;using System.Runtime.Serialization;namespace TelerikMvcMusicStore.ViewModels{ [KnownType(typeof(AlbumViewModel))] public class AlbumViewModel { /// <summary> /// /// </summary> [ScaffoldColumn( false )] public int AlbumId { get; set; } /// <summary> /// /// </summary> [Required( ErrorMessage = "An album title is required" )] [StringLength( 160 )] public string Title { get; set; } /// <summary> /// /// </summary> [Required( ErrorMessage = "Price is required" )] [DataType(DataType.Currency)] public decimal Price { get; set; } /// <summary> /// /// </summary> public string Genre { get; set; } /// <summary> /// /// </summary> public string Artist { get; set; } /// <summary> /// /// </summary> public string ImageUrl { get; set; } }}It works fine if I remove the [DataType] annotation from the Price field but then the input control is a simple textbox rather than the nice numeric textbox. As soon as I add the DataType it errors.
I'm not getting how this works in the example and doesn't work in my project, any insight would be appreciated!
Thanks!!