Telerik Forums
UI for ASP.NET MVC Forum
4 answers
321 views
In your sample: http://www.kendoui.com/code-library/mvc/grid/custom-popup-editor.aspx

When I want to save I get an error that the field birthdate must be a date.

I even set DataType.Date annotation on that model property. But still I get this error.

How can I fix your broken sample?
Petur Subev
Telerik team
 answered on 02 Apr 2015
3 answers
160 views
To reproduce an issue a user recently posted related to Kendo grid, I thought it might be possible for me to use .NET Fiddle for it. But I am not able to load Kendo references. In my application I add a reference to Kendo.Mvc.dll.I am wondering is there a way I can add a reference in .NET fiddle. .NET fiddle supports Nuget package however Kendo MVC wrapper does not come in a package.

My fiddle is: https://dotnetfiddle.net/vRAJfO

Found that Kendo has got a tutorial that let you create charts and play around with it:http://dojo.telerik.com/. But it does not allow you to write ASP.NET MVC style code like .NET Fiddle does.

Is there a way we can create a fiddle using Kendo ASP.NET MVC wrapper?
Dimo
Telerik team
 answered on 02 Apr 2015
2 answers
350 views
I am using kendo grid with detail template, when the detail template binds to the existing grid row, everything works fine. Now I try to use javascript to add dynamic data and bind to the template, I receive javascript error "Email is not defined". It looks like the template's context is set to the current grid, how can i change it to bind to dynamic data, below is my code

@(Html.Kendo().Grid(Model.Customers)
    .Name("GridCustomers")
    .Columns(columns =>
    {
        columns.Bound(p => p.ID).Title("ID");
        columns.Bound(p => p.Name).Title("Name");
        columns.Bound(p => p.Telephone).Title("Telephone");
        columns.Bound(p => p.Extension).Title("Extension");
        columns.Bound(p => p.Group).Title("Group");

    })
    .HtmlAttributes(new { style = "height: 430px;" })
    .Pageable(pageable => pageable.Refresh(true).PageSizes(true).ButtonCount(5))
    .Sortable()
    .Scrollable()
    .ClientDetailTemplateId("template1")
    .DataSource(dataSource => dataSource
        .Ajax()
        .ServerOperation(false)
    )
    .Events(events => events.DetailExpand("onDetailExpand"))

)

<script id="template1" type="text/html">
    <div class='employee-details'>
        Contact Details:
        <ul>
            <li><label>Name:</label>#= Name #</li>
            <li><label>Mobile:</label>#= Telephone #</li>
            <li><label>E-mail Address:</label>#= Email #</li>
        </ul>
    </div>
</script>

<script>
    function dataBound() {
        this.expandRow(this.tbody.find("tr.k-master-row").first());
    }
    function onDetailExpand() {
        var javascriptTemplate = kendo.template($("#template1").html());
        var javascriptData = {FirstName: "Ziming", Telephone: "12345678", Email: "abc@abc.com"};
        $(".employee-details").html(javascriptTemplate(javascriptData));
    }
</script>
Ziming
Top achievements
Rank 1
 answered on 01 Apr 2015
1 answer
790 views
Hi,

I have Kendo MVC editable Grid  with Custom EditorTemplate for Numeric Text Box. For some reason I am getting validation error icon when i  try to update the value in numeric text box as in attached file.

I am not sure what kind of validation it is triggering as I have only required field validation. Can you pelase help me ASAP on this.


My model is as below

[Serializable]
    public class DocTypesModel
    {
        [Required(ErrorMessage = "required")]
        [UIHint("NumericTextBoxWithLimitsTemplate")]
        public int Order { get; set; }

        public int TotalCount { get; set; }

        public string DocumentTypeShortName { get; set; }      

    }

My grid is as below


 @(Html.Kendo().Grid(Model.DocTypesModel)
                      .Name("BookmarkDoctypeGrid")
                   
                     .Columns(columns =>
                      {
                            columns.Bound(c => c.Order).Sortable(false).EditorTemplateName("NumericTextBoxWithLimitsTemplate");
                          columns.Bound(c => c.DocumentTypeShortName).Title("Document Type").Sortable(false);
                        
                      })
                      .Editable(e => e.Mode(GridEditMode.InCell))
                      .Sortable()
                      .Events(e => e.DataBound("OnGridDocTypeDataBound").SaveChanges("SaveDocTypeChanges"))
                      .Resizable(resiz => resiz.Columns(false))
                      .DataSource( dataSource =>
                          dataSource.Ajax()
                           .AutoSync(true)
                           .ServerOperation(false)
                          .Update("Editing_Update", "Bookmark")
                              .Events(events => events.Error("error_handler"))
                        
                      )
                      )

I have created below custom editor for  NumericTextBoxWithLimitsTemplate under /views/shared/EditorTemplates/NumericTextBoxWithLimitsTemplate.cshtml

@model int

@(Html.Kendo()
.NumericTextBox().Step(1)
    .Name("Order").Decimals(0)
    .HtmlAttributes(new { Style = "width:70px;", required="required"})
         .Min(1).Max(short.MaxValue)
         
      

Thanks,
AArti



Boyan Dimitrov
Telerik team
 answered on 01 Apr 2015
4 answers
383 views
Hi Telerik.

I am trying to accomplish a scheduler with horizontal grouping of several resources, say mechanics.
So, I have a day view scheduler with a variable number of mechanics as resources on top, comparable to selecting the day view in this demo. Now, I have included the following code:
@(Html.Kendo().Scheduler<VisitViewModel>()
    .Name("scheduler")
    .Date(DateTime.Now)
    .StartTime(7, 0, 0)
    .EndTime(18, 0, 0)
    .Timezone("Etc/UTC")
    .AllDaySlot(false)
    .Views(views => {
        views.DayView(view => view.Selected(true)
            .WorkDayStart(8, 0, 0)
            .WorkDayEnd(17, 0, 0)
            .SelectedDateFormat("{0:dddd d/M/yyyy}"));
    })

.Resources(resource => resource
        .Add(m => m.MechanicId)
        .Title("Mechanic")
        .Name("mechanic")
        .Multiple(false)
        .DataTextField("Text")
        .DataValueField("Value")
        .BindTo(GetMechanics().Select(v => new { Text = String.Format("{0} {1}", v.FirstName, v.LastName), Value = v.Id }).ToArray()))

However, using the above code all mechanics obviously have exactly the same working hours, that is, from 8:00 to 17:00.
Imagine that I have two mechanics, say A and B, and that mechanic A usually works from 8:00 to 17:00 and mechanic B from 9:00 to 18:00.

How can I easily achieve this as the number of mechanics is variable and a mechanic's working hours is extracted from the database for a specific date?
What I would like to accomplish is to add the css class k-nonwork-hour to a resource's (mechanic) unavailable hours. I have an idea of how to obtain the desired result with javascript, but this approach is quite extensive and its code is complex to write and maintain. I wonder whether there's an easier way to achieve this.

I have already resolved this server-side so that you cannot drag and drop an event into a mechanic's unavailable hours, but I would like to show this unavailability visually in the scheduler itself as well.

I am looking forward to hearing from you soon. Thanks in advance!

Kind regards,
Mor
Mor
Top achievements
Rank 1
 answered on 01 Apr 2015
3 answers
115 views
Hi

I have implemented below custom validation rule. It works but it triggers a controller method twice once on Edit of cell and once Closure of cell. I just wanted it to be triggered on closure of cell. Can you please help me on this. Thank you

My property in in my Model is as below

 [Remote("IsUniqueDisplayName", "Bookmark", AdditionalFields = "DocumentTypeId", ErrorMessage = "Display Name must be Unique.")]
 public string DocumentTypeSortNameTitle { get; set; }

Custom validation rule implementation in javascript as below

 (function ($, kendo) {
        $.extend(true, kendo.ui.validator, {
            rules: {
                mvcremotevalidation: function (input) {
                    if (input.is("[data-val-remote]") && input.val() != "") {
                        var remoteURL = input.attr("data-val-remote-url");
                        var valid = true;
                        var td = input.parent('td');
                        if (td.hasClass("k-dirty-cell")) {
                            var found = false;
                            $.ajax({
                                async: false,
                                url: remoteURL,
                                type: "GET",
                                dataType: "json",
                                data: validationData(input, this.element),
                                success: function (result) {
                                    found = result;
                                    if (found)
                                        valid = false;
                                    else {
                                        valid = true;
                                    }
                                },
                                error: function () {
                                    valid = false;
                                }
                            });
                        }
                       return valid;
                      
                    }

                    return true;
                }
            },
            messages: {
                mvcremotevalidation: function (input) {
                     return input.attr("data-val-remote");
                  //  return "Display Name must be Unique";
                }
            }
        });

        function validationData(input, context) {
            var grid = $("#BookmarkDoctypeGrid").data("kendoGrid");
            var currentData = grid.dataSource.data();
            var uid = $("#BookmarkDoctypeGrid").find('.k-edit-cell').parent('tr').data('uid');
            var dataItem = grid.dataSource.getByUid(uid);
            var documentTypeId = dataItem.DocumentTypeId;
            var fields = input.attr("data-val-remote-additionalFields").split(",");
            var name = input.prop("name");
            var prefix = name.substr(0, name.lastIndexOf(".") + 1);
            var fieldName;
            var data = {};
            for (var i = 0; i < fields.length; i++) {
                fieldName = fields[i].replace("*.", prefix);
                if (fieldName == 'DocumentTypeId') {
                    data[fieldName] = documentTypeId;
                } else
                    {
                    data[fieldName] = $("[name='" + fieldName + "']", context).val();
                }
            }            
            return data;
        }
    })(jQuery, kendo);
Petur Subev
Telerik team
 answered on 01 Apr 2015
1 answer
670 views
Hi,


I have a dropdown list binding to a datasource with duplicate records. Is there any way I  can remove the duplicate items in the dropdown list? I don't want to remove the duplicate records in the datasource because it is shared by a grid. Thanks.
Georgi Krustev
Telerik team
 answered on 01 Apr 2015
5 answers
1.0K+ views
I have wired up a simple grid with some bound columns and one of those columns I'm trying to create a hyperlink.  Here is my code:

@(Html.Kendo().Grid(Model.CareAlerts)
    .Name("Alerts")
    .Columns(columns =>
    {
        columns.Bound(p => p.AlertDate).Title("Date").Format("{0:d}");
        columns.Bound(p => p.PatientName).Template(@<text>
            @Html.ActionLink(@item.PatientName, "Member", new { id = @item.PatientASID })
        </text>);
        columns.Bound(p => p.AlertSummary).Title("Message");
    })
                                        .Sortable()
                                        .DataSource(dataSource => dataSource
                                                .Ajax()
                                                .PageSize(20)
                                                .ServerOperation(false)
                                             )
            )

The second column is the column where I'm attempting to show the hyperlink.  Now, when I render the page, I can see the hyperlink for a split second before it disappears and I just see the text is supposed to be included in the link, but it is not linked after that.

Now, here's the funny thing:  If I remove the reference to kendo.aspnetmvc.min.js in my BundleConfig.cs file, the hyperlinks show up just fine, however, I get a "Script not included" error if I do this.

Any idea what I'm doing wrong?
Dimiter Madjarov
Telerik team
 answered on 31 Mar 2015
2 answers
111 views
Is anyone else having issues with the standard filtering functionality on a ForeignKey column with the latest release?  After upgrading, I noticed in a project of mine the Filter button was not causing a datasource read, and also went to the demo page (http://demos.telerik.com/aspnet-mvc/grid/foreignkeycolumn) and was getting the same behavior across different browsers (no sign of any Javascript errors in various browser debuggers).

From that demo page, if I go to filter the Category column on "Beverages", no filter event seems to fire.  However, if I go to the the Unit Price column and hit the "Clear" button and then go back to the Category column and filter on "Beverages" again, it properly filters.

Seems to affect the Kendo UI version of the demo the same way from what I can see

Regards,
Toby
Atanas Georgiev
Telerik team
 answered on 31 Mar 2015
3 answers
169 views
How can I designate route based on marker list and show route on map? At now I have only added markes.

Code form my View:
@(Html.Kendo().Map()
    .Name("Bing")
    .Center(53.4252981, 14.5526117)
    .Zoom(12)
    .Layers(layers =>
    {
        layers.Add()
            .Type(MapLayerType.Bing)
            .ImagerySet(MapLayersImagerySet.Road)           
            .Key("key");
        layers.Add()
            .Type(MapLayerType.Marker)
            .DataSource(dataSource => dataSource
                  .Read(read => read.Action("_StoreLocations", "Home"))
            )
            .LocationField("LatLng")
            .TitleField("Title");
        layers.Add()
            .Type(MapLayerType.Shape)
            .DataSource(dataSource => dataSource
                  .Read(read => read.Action("_StoreLocations", "Home"))
            )
            .LocationField("LatLng")
            .TitleField("Title");
    })
)

Best regards,
Michał
T. Tsonev
Telerik team
 answered on 31 Mar 2015
Narrow your results
Selected tags
Tags
+? more
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?