Telerik Forums
UI for ASP.NET Core Forum
1 answer
438 views

Hi All,

I want to add a clear filter button on my grid toolbar. How can I achieve this? 

Is it possible to get each filter changes in array?

Like for instance my I set my 1st filter to column status to show only Active  

My 2nd filter is user type admin on user type column

and my 3rd filter to First Name column is Ryan

 

So if I click the button Clear filter, it will only clear my 3rd filter for First name

and when I click the 2nd time, it will clear my filter for User type Admin

and when I click again the 3rd status active will be cleared.

 

Actually my main goal here is to put this array in to bread crumb. although I cant seem to make breadcrumb work in my grid toolbar. so button would suffice for now.

 

Viktor Tachev
Telerik team
 answered on 19 Feb 2020
1 answer
326 views

Hello all, I hope you can point me in the right direction.

 

My requirement is to show validation messages (whether from Data Annotation [Required] attributes, etc., or from the server-side via ModelState Errors) in an error message block at the top of the editor, not next to the fields which the errors are related to. I am showing errors in a Kendo Notification that is present on my _Layout.cshtml page (I declared it there in hopes that I could have some of my CRUD error handling done in one place instead of each and every view...)

 

Problem

The problem that I am having is that if you try to submit my form without entering required data, you're shown the errors at the top, correctly. Then, if you correct the errors that were from the model's data annotations and don't cause any server-side errors, the popup permanently stays in "loading" mode and never closes. If you then F5 to refresh, the record does save to the database.

 

I've been tinkering with my code all day to try and magically get it to work, but this generally should show what I'm trying to do.

First, I added logic to the .Edit event of my Grid:

    function onEdit(e) {
        e.sender.editable.validatable.bind("validate", function (e) {
            SendErrorsToNotification(this.errors()); // SendErrorsToNotificationis the js function to take incoming errors and show them in the Kendo Notification
        });
    };

My hope here is that I will "intercept" the kendo validation for data annotations, get the errors, and then show them in my Kendo Notification. Errors are currently being displayed using this logic - whether my problem is stemming from here is another question.

 

Next, server-side validation. Inside my Create/Update actions I simply have a Validate function defined to do business logic validation, i.e. this:

                var validationErrors = Validate("Create", brand);
                foreach (string error in validationErrors.Distinct())
                {
                    ModelState.AddModelError("BasicValidation", error);
                }
                ...

                return Json(new[] { viewmodel}.ToDataSourceResult(request, ModelState));

 I capture these errors by handling the .Error event of my grid, and call the same SendErrorsToNotification function again:

 function error(e) {
         SendErrorsToNotification(e.errors);
     }

This is SendErrorsToNotification. Basically, create an error collection based on the incoming parameter, clear the notification of its existing data, then add the new errors and show the Notification again.

function SendErrorsToNotification(e) {
    var staticNotification = $("#statusNotification").data("kendoNotification");

    if (e.length > 0 || (e.BasicValidation !== undefined && e.BasicValidation.errors.length > 0)) {

        if (e.errorThrown === "custom error") {
            // custom rtc errors from server side, gather the errors up and place them into e.errors so the rest of this function can run smoothly
            e.errors = e.errors.BasicValidation.errors;
        }

        var grid = $(".grid-with-notifications").data("kendoGrid");
        grid.one("dataBinding", function (g) {
            g.preventDefault();
        });

        // Clear existing messages from the notification.
        var existingNotifications = staticNotification.getNotifications();
        existingNotifications.each(function () { 
            $(this).remove();
        });

        var errorMessage = "";
        $.each(e, function (key, value) {
            errorMessage += "&bull;&nbsp;&nbsp;" + this + "<br/>";
        });

        staticNotification.show(errorMessage, "error");

        var container = $(staticNotification.options.appendTo);
        container.scrollTop(container[0].scrollHeight);
    }
    else {
        staticNotification.hide();
    }

 

I really apologize for not being able to format any of this code as code, for some reason my browser isn't "showing advanced formatting options" while creating this post. Sorry for the wall of text, hopefully someone can read my mind (and scattered code) and help me understand some of my short comings here. I have been fairly stumped by this for a few days now and getting quite sad :(

Tsvetomir
Telerik team
 answered on 18 Feb 2020
3 answers
553 views

 

Below is from a sample app I generated, from the _Layout.cshtml file.  If you look at the kendo.cdn.telerik.com/2019.3.1023/js/jquery.min.js file, its using a really old version of jQuery.  How can we use a more current version?

 

    <link href="htt    <link href="https://kendo.cdn.telerik.com/2019.3.1023/styles/kendo.bootstrap-v4.min.css" rel="stylesheet" type="text/css" />

    <script src="https://kendo.cdn.telerik.com/2019.3.1023/js/jquery.min.js"></script>
    <script src="https://kendo.cdn.telerik.com/2019.3.1023/js/jszip.min.js"></script>
    <script src="https://kendo.cdn.telerik.com/2019.3.1023/js/kendo.all.min.js"></script>
    <script src="https://kendo.cdn.telerik.com/2019.3.1023/js/kendo.aspnetmvc.min.js"></script>

Martin
Telerik team
 answered on 17 Feb 2020
5 answers
241 views

Hi Dear

I use Telerik components in our web.

in one of a web form the cursor inside a textbox causes flickering all around.

what can the reason for this?

Thanks 

Haim

Dimitar
Telerik team
 answered on 17 Feb 2020
1 answer
214 views

The main codes are as follows. When the treelist loaded, Always show alert once. Then click the custom toolbar button, Nothing do!

@(Html.Kendo().TreeList<Liwb.Entities.RulesAndRegulation>
    ()
    .Name("Treelist")
    .Toolbar(toolbar =>
    {
        toolbar.Custom().Name("cust").Text("Upload").Click("uploadfile()");
    })
    .Columns(columns =>
    {
        columns.Add().Field(f => f.Name);
        columns.Add().Field(e => e.ReleaseUnit);
        columns.Add().Field(e => e.ReleaseNumber);
        columns.Add().Field(e => e.EffectiveDate).Format("{0:yyyy/M/d}");
        columns.Add().Field(e => e.Type).Template("#: displayEnum(data)#");
        columns.Add().Width(400).Command(c =>
        {
            c.CreateChild().Text("附件");
            c.Edit();
            c.Destroy();
        }).HtmlAttributes(new
        {
            style = "text-align: center;"
        });
    })
    .Editable()
    .Scrollable(false)
    .Filterable()
    .DataSource(dataSource => dataSource
        .ServerOperation(false)
        .Model(m =>
            {
                m.Id(f => f.ID);
                m.ParentId(f => f.PID);
                m.Field(f => f.Name);
                m.Field(f => f.Pos).DefaultValue(1);
                m.Field(f => f.Type).DefaultValue(Liwb.Utility.RulesAndRegulationType.dc3);
            })
        .Create(create => create.Action("Create", "RulesAndRegulation"))
        .Read(read => read.Action("Read", "RulesAndRegulation"))
        .Update(update => update.Action("Update", "RulesAndRegulation"))
        .Destroy(delete => delete.Action("Destroy", "RulesAndRegulation"))
        )
        .Height(540)
        .Pageable(p => p.PageSize(15)
        .PageSizes(true)
        )
    )
    <script type="text/javascript">
        function uploadfile() {
            alert("My upload!");
        }
    </script>

Nikolay
Telerik team
 answered on 17 Feb 2020
3 answers
552 views

 

how to bind this column to TextArea in asp.net core project in edit template 

this my steps but it's not working 

column.Bound(c => c.Note).EditorViewData("TextArea");

[UIHint("TextArea")]
public string Note
{
    get;
    set;
}

Views/Shared/EditorTemplates/TextArea.cshtml
@model string

@Html.TextAreaFor(m=>m, new { rows = 5})

 

 

 

 
Mohammed
Top achievements
Rank 1
 answered on 15 Feb 2020
1 answer
125 views

Say I have a typical declaration like this:

 

@(Html.Kendo().ComboBox().Name("cb")
     .DataTextField("Name")
     .DataValueField("ID")
     .DataSource(source => {
          source.Read(read => {
                read.Action("GetTest", "Home");
           })
       .ServerFiltering(true);
       }).Events(e => e.Change("onCBChange"))

 

How does the syntax look for replacing that e.Change("onCBChange") with an anonymous function? I'm thinking something like this, but I can't seem to get it right

 

.Events(e => e.Change {

    function(f) { 

         alert("here!");

} )

Scott
Top achievements
Rank 1
Veteran
 answered on 14 Feb 2020
0 answers
59 views
look the attachment,my computer screen is 2K DPI.
wu
Top achievements
Rank 1
Veteran
 asked on 14 Feb 2020
0 answers
110 views

My computer screen is 14 inch, 2560x1440, when open the pdf file in AspNet core PDFViewer,

the font is fuzzy .

At the same time, the all FileDialog's font is fuzzy .

wu
Top achievements
Rank 1
Veteran
 asked on 14 Feb 2020
3 answers
131 views

 

Is there a way to do this in code?

Thanks … Ed

 

Ivan Danchev
Telerik team
 answered on 14 Feb 2020
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?