Telerik Forums
UI for ASP.NET MVC Forum
6 answers
1.0K+ views
Hello there,

I have a quick question on how the grid picks up the validation attribute we have on the model.  My grid has batch editing enabled and there's a column bound to the "Name" property of my model.  The Name property is decorated with the [Required] attribute and the required field validator works out of the box, which is nice.  However if I replace [Required] with [RequiredCustom] (where RequiredCustomAttribute is my own class that extends RequiredAttribute), the grid will ignore it and the required field validation will not kick in.  The reason for having the RequiredCustomAttribute is so I can have a logic to build up the validation message from the database.  Back in the old days of Telerik ASP.NET MVC, the grid didn't have any issue picking up my [RequiredCustom].  Has there been a change in this area for Kendo UI for MVC?

Thanks,

Ben
ben
Top achievements
Rank 1
 answered on 14 Jun 2012
1 answer
740 views
Hi I am  using Kendo.MVC.dll:
In MS Sql (2012) table I have column:

    Day Data Type datetime

In the controller I get the data using"
 

      public ActionResult BloodPressure_Read([DataSourceRequest] DataSourceRequest request)
            {
             return Json(BPRepository.All().ToDataSourceResult(request));
            }

In the view:

    @(Html.Kendo().Grid<BPViewModel>()
    
        .Name("Grid")
        .Columns(columns =>
        columns.Bound(p => p.Day).Format("{0:d}");

The date is displayed as 1/1/2012; however when I edit it (using Ajax) it shows as Sun Jan 1 00:00:00 PST 2012!!  When I try to update the row, I get "Day is invalid Date.

Any idea how I can convert the date to yyyy,mm, dd?
Thanks in advance.
Daniel
Telerik team
 answered on 14 Jun 2012
0 answers
256 views
I have index.cshtml as follows:

@model IEnumerable<Dadavani.Models.Dad_Repost_Transaction>
@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@{
    ViewBag.Title = "Repost";
}
<script src="../../Scripts/Kendo/jquery.min.js" type="text/javascript"></script>
<script src="../../Scripts/Kendo/kendo.web.min.js" type="text/javascript"></script>
<script src="../../Scripts/Kendo/kendo.aspnetmvc.min.js" type="text/javascript"></script>
<script src="../../Scripts/Kendo/console.js" type="text/javascript"></script>
 
 
 
 
<link href="../../Content/Kendo/kendo.common.min.css" rel="stylesheet" type="text/css" />
<link href="../../Content/Kendo/kendo.default.min.css" rel="stylesheet" type="text/css" />
 
 
<h2>Repost</h2>
@(Html.Kendo().Grid(Model)   
    .Name("Grid")
    .Columns(columns =>
    {
        columns.Bound(model => model.SR_NO);
        columns.Bound(model => model.MEMBER_ID);
        columns.Bound(model => model.R_MONTH);
        columns.Bound(model => model.PRINT_YN);
        columns.Command(command => { command.Edit(); command.Destroy(); }).Width(200);
    })
    .ToolBar(toolbar =>
    {
        toolbar.Create();
    })
    .Editable(editable => editable.Mode(GridEditMode.InLine))
    .Groupable()
    .Pageable()
    .Sortable()
    .Scrollable()
    .Filterable()            
    .DataSource(dataSource => dataSource
        .Ajax()
            .Model(p => p.Id(model => model.SR_NO))
            .Create(update => update.Action("Create", "Repost"))
            //.Read(read => read.Action("GetReposts", "Repost"))
            .Read(read => read.Action("Read", "Repost"))
            .Update(update => update.Action("Update", "Repost"))
            .Destroy(update => update.Action("Destroy", "Repost"))
    )
    
)
<div id="Grid"></div>

read works fine showing all records. When I click 'Add New Record', it shows error as follows.

This request has been blocked because sensitive information could be disclosed to third party web sites when this is used in a GET request. To allow GET requests, set JsonRequestBehavior to AllowGet

the method I created is as follows which is similar to UI Kendo MVC examples. So, what is the problem?

[AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Create([DataSourceRequest] DataSourceRequest request, Dad_Repost_Transaction repost)
        {
 
            if (repost != null && ModelState.IsValid)
            {
                    context.Reposts.Add(repost);
                    context.SaveChanges();
            }
 
            return Json(new [] { repost }.ToDataSourceResult(request, ModelState),JsonRequestBehavior.AllowGet);
           
        }
Hetal
Top achievements
Rank 1
 asked on 14 Jun 2012
2 answers
74 views
Hi there,

I'm not sure if this is a known issue.  For a command column and a bound column with Filterable(false), the filter icon on top on the column still shows.  I suppose this has something to do with the MVC wrapper as it was working fine earlier on the regular Kendo UI.  Please let me know if you need more info on reproducing the bug.

Thanks,

Ben
ben
Top achievements
Rank 1
 answered on 13 Jun 2012
5 answers
215 views
Hi.
I have been testing MVC Kendo.

Testing Grid has an unexpected behavior (see attached image grid_twice.png).

That render is result of the following code:
view:
@model IEnumerable<_2TrackControl.MVC4.Models._2TrackControl.KitViewModel>
@using Kendo.Mvc.UI
@{
    ViewBag.Title = "Index";
}
<h2>
    Index</h2>
<p>
    @Html.ActionLink("Create New", "Create")
</p>
@(Html.Kendo().Grid(Model)   
    .Name("Grid")
    .Columns(columns =>
    {
        columns.Bound(p => p.ClientSetName).Groupable(false);
        columns.Bound(p => p.IMEI);
        columns.Bound(p => p.Active);
        columns.Bound(p => p.Inserted);
    })
    .Groupable()
    .Pageable()
    .Sortable()
    .Scrollable()
    .Filterable()            
    .DataSource(dataSource => dataSource
         
        .Ajax()
        .Read(read => read.Action("_Index", "Kit"))       
    )
)
and actions:

private Entities db = new Entities();
  
//
// GET: /Kit/
  
public ActionResult Index()
{
    var kitset = db.KitSet.Include("ClientSet");
  
    Mapper.CreateMap<KitSet, KitViewModel>();
    var resultReturn = Mapper.Map<List<KitSet>, List<KitViewModel>>(kitset.ToList());
  
    return View(resultReturn);
}
  
public ActionResult _Index([DataSourceRequest] DataSourceRequest request)
{
    var kitset = db.KitSet.Include("ClientSet");
  
    Mapper.CreateMap<KitSet, KitViewModel>();
    var resultReturn = Mapper.Map<List<KitSet>, List<KitViewModel>>(kitset.ToList());
    return Json(resultReturn.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
}

Can you figure what is happening?
Thanks
figueiredorj
Top achievements
Rank 1
 answered on 13 Jun 2012
3 answers
201 views
I have an integer column with filtering enabled. While equal to, less than, and greater than filter works, less than or equal to and greater than or equal to filtering throws this exception:

[NullReferenceException: Object reference not set to an instance of an object.]
Kendo.Mvc.Infrastructure.Implementation.FilterNodeVisitor.Visit(PropertyNode propertyNode) +42
Kendo.Mvc.Infrastructure.Implementation.PropertyNode.Accept(IFilterNodeVisitor visitor) +10
Kendo.Mvc.Infrastructure.FilterDescriptorFactory.Create(String input) +128
Kendo.Mvc.UI.DataSourceRequestModelBinder.BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) +213
System.Web.Mvc.ControllerActionInvoker.GetParameterValue(ControllerContext controllerContext, ParameterDescriptor parameterDescriptor) +317
System.Web.Mvc.ControllerActionInvoker.GetParameterValues(ControllerContext controllerContext, ActionDescriptor actionDescriptor) +117
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +324
System.Web.Mvc.Controller.ExecuteCore() +106
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +91
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
System.Web.Mvc.&lt;&gt;c__DisplayClassb.&lt;BeginProcessRequest&gt;b__5() +34
System.Web.Mvc.Async.&lt;&gt;c__DisplayClass1.&lt;MakeVoidDelegate&gt;b__0() +19
System.Web.Mvc.Async.&lt;&gt;c__DisplayClass8`1.&lt;BeginSynchronous&gt;b__7(IAsyncResult _) +10
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
System.Web.Mvc.&lt;&gt;c__DisplayClasse.&lt;EndProcessRequest&gt;b__d() +48
System.Web.Mvc.SecurityUtil.&lt;GetCallInAppTrustThunk&gt;b__0(Action f) +7
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9615056
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously) +155
Iliana Dyankova
Telerik team
 answered on 12 Jun 2012
1 answer
224 views
Title says it all, I have a fairly simple POCO mapped to a database using nHibernate and I'm using server binding to build my grid. I am auto generating my columns in the grid but properties on my POCO that are decorated with [ScaffoldColumn(false)] are still being shown in my grid. However I will note that they are correctly being ignored on the popups generated from making the grid editable.
Html.Kendo().Grid(Model)
    .Name("Grid")
        .Columns(columns =>
            {
                columns.AutoGenerate(true);
                columns.Command(command =>
                    {
                        command.Edit();
                    });
            })
    .ToolBar(toolbar => toolbar.Create())
    .Editable(editable => editable.Mode(GridEditMode.PopUp))

Iliana Dyankova
Telerik team
 answered on 12 Jun 2012
5 answers
446 views
Hi. 
I am having an used (I think) issue on grid.
"The DataKeys collection is empty. Please specify a data key."

For telerik mvc extensions it is documented issue but I don't find how to fix it with kendo MVC
My grid:
@(Html.Kendo().Grid(Model)
 
    .Name("Grid")
    .Columns(columns =>
                 {
                      
                     columns.Bound(p => p.ClientSetName).Width(100).Title("Client");
                     columns.Bound(p => p.IMEI).Width(100).Title("IMEI");
                     columns.Bound(p => p.Active).Width(200).Title("Active");
                     columns.Bound(p => p.Inserted).Title("Inserted");
                     columns.Command(commands =>
                     {
                         commands.Edit();
                     }).Width(200);
                 })
 
        .Groupable()
        .Pageable()
        .Sortable()
        .Scrollable()
        .Filterable()
        .DataSource(dataSource => dataSource
            .Ajax()
            .Read(read => read.Action("_Index", "Kit"))
        )
)
and my ViewModel:
public class KitViewModel
{
    [ScaffoldColumn(true)]
    [UIHint("Kit")]
    public Guid Id { get; set; }
 
    [StringLength(15), Required]
    [DisplayName("IMEI")]
    public string IMEI { get; set; }
 
    [ReadOnly(true)]
    [DisplayName("Active")]
    public bool Active { get; set; }
 
    [DisplayFormat(DataFormatString = "{0:dd MM yyyy}")]
    [DataType(DataType.DateTime), Required]
    [ReadOnly(true)]
    [DisplayName("Inserted")]
    public DateTime Inserted { get; set; }
 
    [DisplayFormat(DataFormatString = "{0:dd MM yyyy}")]
    [DataType(DataType.DateTime), Required]
    [ReadOnly(true)]
    [DisplayName("Updated")]
    public DateTime Updated { get; set; }
 
    [UIHint("Client")]
    [ScaffoldColumn(true)]
    public Guid ClientId { get; set; }
 
    [DisplayName("Client")]
    public string ClientSetName { get; set; }
}
How can I fix this in kendo mvc?
Thanks
Rosen
Telerik team
 answered on 11 Jun 2012
0 answers
198 views
hello

I have following Index view in index.cshtml

@{
    ViewBag.Title = "Repost";
}
<script src="../../Scripts/Kendo/kendo.web.min.js" type="text/javascript"></script>
<script src="../../Scripts/Kendo/console.js" type="text/javascript"></script>
 
<script src="../../Scripts/Kendo/jquery.min.js" type="text/javascript"></script>
 
 
<link href="../../Content/Kendo/kendo.common.min.css" rel="stylesheet" type="text/css" />
<link href="../../Content/Kendo/kendo.default.min.css" rel="stylesheet" type="text/css" />
 
 
<h2>Repost</h2>
 
<div id="grid"></div>
<script type="text/javascript">
    $(document).ready(function () {
        debugger;
        var dataSource = new kendo.data.DataSource({
            transport: {
                read: {
                    url: "Repost/Index",
                    dataType: "json",
                    type: "POST"
                }
            },
            schema: {
                data: "reposts"
            }
        });
        $("#grid").kendoGrid({
            dataSource: dataSource,
            autobind: true,
            columns: [
                    { title: "SR NO", field: "SR_NO" },
                    { title: "MEMBER ID", field: "MEMBER_ID" },
                    { title: "MONTH", field: "R_MONTH" },
                    { title: "PRINT Y/N?", field: "PRINT_YN" }
                ],
            height: 360,
            groupable: false,
            sortable: false,
            pageable: false,
            scrollable: false
        });
    });
    </script>

and in Repost controller I have following method

public class RepostController : Controller
    {
          
        public JsonResult Index()
        {
            DadavaniContext context = new DadavaniContext();
            var result = context.Reposts.OrderByDescending(r => r.SR_NO).ToList();
 
            var allReposts = from c in result select new[] { Convert.ToString(c.SR_NO), c.MEMBER_ID, c.R_MONTH, c.PRINT_YN };
 
            return Json(new { reposts = allReposts }, JsonRequestBehavior.AllowGet);
             
        }
 
    }

When I run the application, it shows Json data directly as follows but not in Index view's grid. What is going wrong?
Hetal
Top achievements
Rank 1
 asked on 11 Jun 2012
0 answers
164 views
hi,
i want to display tabs in vertical direction in the right corner,can u suggest me how to place the tabs vertically
charan
Top achievements
Rank 1
 asked on 10 Jun 2012
Narrow your results
Selected tags
Tags
Grid
General Discussions
Scheduler
DropDownList
Chart
Editor
TreeView
DatePicker
ComboBox
Upload
MultiSelect
ListView
Window
TabStrip
Menu
Installer and VS Extensions
Spreadsheet
AutoComplete
TreeList
Gantt
PanelBar
NumericTextBox
Filter
ToolTip
Map
Diagram
Button
PivotGrid
Form
ListBox
Splitter
Application
FileManager
Sortable
Calendar
View
MaskedTextBox
PDFViewer
TextBox
Toolbar
MultiColumnComboBox
Dialog
DropDownTree
Checkbox
Slider
Switch
Notification
Accessibility
ListView (Mobile)
Pager
ColorPicker
DateRangePicker
Security
Wizard
Styling
Chat
DateInput
MediaPlayer
TileLayout
Drawer
SplitView
Template
Barcode
ButtonGroup (Mobile)
Drawer (Mobile)
ImageEditor
RadioGroup
Sparkline
Stepper
TabStrip (Mobile)
GridLayout
Badge
LinearGauge
ModalView
ResponsivePanel
TextArea
Breadcrumb
ExpansionPanel
Licensing
Rating
ScrollView
ButtonGroup
CheckBoxGroup
NavBar
ProgressBar
QRCode
RadioButton
Scroller
Timeline
TreeMap
TaskBoard
OrgChart
Captcha
ActionSheet
Signature
DateTimePicker
AppBar
BottomNavigation
Card
FloatingActionButton
Localization
MultiViewCalendar
PopOver (Mobile)
Ripple
ScrollView (Mobile)
Switch (Mobile)
PivotGridV2
FlatColorPicker
ColorPalette
DropDownButton
AIPrompt
PropertyGrid
ActionSheet (Mobile)
BulletGraph
Button (Mobile)
Collapsible
Loader
CircularGauge
SkeletonContainer
Popover
HeatMap
Avatar
ColorGradient
CircularProgressBar
SplitButton
StackLayout
TimeDurationPicker
Chip
ChipList
DockManager
ToggleButton
Sankey
OTPInput
ChartWizard
SpeechToTextButton
InlineAIPrompt
TimePicker
StockChart
RadialGauge
ContextMenu
ArcGauge
AICodingAssistant
SegmentedControl
+? more
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?