Telerik Forums
UI for ASP.NET Core Forum
0 answers
137 views

In our UI for ASP.NET Core R3 2020 (2020.3.915) release, the Column menu message of unsticking a column is "null".

This bug will be resolved in our next official release.

In the meantime, as a workaround, manually set the Unstick Column menu message:

.ColumnMenu(c => c.Messages(m => m.Unstick("Unstick Column")))
Kendo UI
Top achievements
Rank 1
 asked on 16 Sep 2020
0 answers
4 views

After updating a working .NET 5 project to .NET 6 and upgrading Nuget package Telerik.UI.for.AspNet.Core from 2021.2.511 to 2022.2.510, I am now receiving an error using IntegerTextBoxFor on an object property model. The error is

FileNotFoundException: Could not load file or assembly 'Microsoft.DotNet.InternalAbstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.

 

Below are screen shots of:

  1.  The exception
  2.  The Nuget packages 1.) From the .NET 5 working solution and 2.) from the .NET 6 solution that crashes.
  3. The line of code that causes the exception. Note that if I bind to a simple property instead of a complex object property, the error does not happen.



Nuget Package Telerik.UI.for.AspNet.Core

The Nuget package on the left is referencing version 2021.2.511. As you can see, that version includes a reference to the file that is causing the error, which is Microsoft.DotNet.InternalAbstractions. The package on the right is referencing the latest version 2022.2.510 and that package does not include the file that is causing the error.

 


@(Html.Kendo().IntegerTextBoxFor(x => x.Product.Odometer)
    .Min(0)
    .Culture(Localizer.CultureCode)
 )

 

If this file is still a dependency of that particular Telerik package, why is it missing? And please advise on how to fix this.

Thank You,
dbeard

Donny
Top achievements
Rank 1
 asked on 17 May 2022
0 answers
3 views

Hello all,

Could someone point me to an example or suggest the best approach for this? The application is asp.net core 5 using Razor.

I am using GridColumnSettings in my grid because there is one SQL table to populate many different pages & we change elements based on the context of use.

On one page, we've added a custom function to the filtering for one column so that we can provide a SQL "IN" condition.  This is working great. However for that one column, can someone suggest how to provide a custom filter menu so that we restrict what options are provided. (Users are going to be confused if they have options on the filter menu that do not work as they expected...)

I've tried a few examples found from searching this site but none seem to work.  Either I got it wrong (for possible) or  because of the columns.LoadSettings<Model.columns> from the server side, it doesn't execute any client side code on the .cshtml page.

I've included the relevant code below.

Any suggestions or examples will be greatly appreciated.  Thank you.

This is the grid on the .cshtml page.

<div id="griddiv">
    @(Html.Kendo().Grid<HPK_DATA>(Model.testdata)    
    .Name("grid")
    .Columns(columns => {
       columns.LoadSettings(Model.columns);
    })
    .Events(ev=>{
        ev.Filter("onFilter");
        //ev.FilterMenuInit("filterMenuInit");
    })
    .Pageable()
    .Sortable()
    .Scrollable()
    .Filterable()
    .DataSource(dataSource => dataSource
        .Ajax()
        .PageSize(20)
        .Read(read => read.Url(Url.Action()+"?handler=Read").Data("forgeryToken"))
     )
)
</div>

This is a portion of the gridcolumnsetting code for brevity.  The column that needs a custom filter menu is the SERIAL_NO.

  IList<GridColumnSettings> columns = new List<GridColumnSettings>
 {
                  new GridColumnSettings
            {
                Member = "ROWID",
                Title = "Id",
                Visible = false,
                Width = "15px",
                Filterable = true

            },
                   new GridColumnSettings
            {
                Member = "ITEM_NO",
                Title = "Item No.",
                Visible = true,
                Width = "150px",
                Filterable = true

            },
                     new GridColumnSettings
             {
                Member = "SERIAL_NO",
                Title = "Serial No.",
                Visible = true,
                Width = "150px",
                Filterable = true
                               
            },
Marianne
Top achievements
Rank 1
Iron
 updated question on 17 May 2022
0 answers
2 views

Hi there

I have a grid with draggable functionality but if I enable the default sort the drag & drop won't work any more.

 

I'm setting the default sort in jquery:

grid.dataSource.sort({ field: "Id", dir: "asc" });

 

I've tried to do it in C# code but got the same results.

 

Can anyone help me with it ?

 

Thanks

Asad
Top achievements
Rank 1
 asked on 17 May 2022
0 answers
3 views

We have a grid of data items that we are editing with a custom popup editor. In the popup is a dropdown list to a foreign key field. When we're editing we need the dropdown list to contain all items so that the existing values show correctly but when we're adding a new record the dropdown list must only show the items in the dropdown where the parent entity does not already have a record associated with that related entity.

So, an example scenario is we have a list of companies and a list of products and some companies have discounts for certain products - a separate company discount table. We navigate to a view with a grid of discounts for a chosen company. In the list of company discounts there is a foreign key to the product. When an edit of one of these discount records is performed the popup opens and the dropdown is populated with all products and the dropdown is made readonly. When a new "discount" record is added, the popup opens and it needs to filter the dropdown items to just those products where the company doesn't already have a discount. We have all the controller code deriving the correct data but we have an issue. When the popup opens for an edit the dropdown data source "read" action executes but at that point in time the id of the parent object hasn't been initialised so it always looks like we are adding a new record - the id is showing as 0. We've added an additional call to the datasource.read on document.ready effectively forcing it to derive the data twice and that then populates the dropdown successfully but it no longer seems to be bound to the field as the current value is not selected. Additionally, when we open the popup for a new record we need to pass in the company id which we know from the grid view but can't seem to get to populate the model object that the popup is bound to. I've searched the web and forums and so far not managed to find a matching scenario. Do you have some advice on how to resolve these issues?

Thanks in advance

PaulH
Top achievements
Rank 1
 asked on 17 May 2022
1 answer
6 views

Hey,

Let's say that I have a ListView with comments:


@(Html.Kendo().ListView<Adelante_ERP_GSBK.Models.ProjectComment>()
                    .Name("listView")
                    .TagName("div")
                    .ClientTemplateId("template")
                    .HtmlAttributes(new {style = "border: none;"})
                    .DataSource(dataSource => dataSource
                        .Ajax()
                        .Read(read => read.Action("GetComments", "ProjectComment", new {projectId = Model.Id}))
                    ))

Template


<script type="text/x-kendo-tmpl" id="template">
<div class="post">
    <div class="user-block" style="margin-bottom: 0;">
        <span class="username" style="display: inline; margin-left: 10px;">
            #:User.Name#
        </span>
        <span class="description" style="display: inline; margin-left: 5px">
            #:kendo.toString(CommentDate, "d")#
        </span>
        <a onclick="showInPopup('@Url.Action("AddOrEdit", "ProjectComment", null, Context.Request.Scheme)/#:Id#', 'Edit')" style="cursor: pointer;" title="Dodaj">
            <i class="fa-solid fa-pen-to-square"></i>
        </a>
        <a onclick="showInPopup('@Url.Action("Delete", "ProjectComment", null, Context.Request.Scheme)/#:Id#', 'Delete?')" style="cursor: pointer;" title="UsuĊ„">
             <i class="fa-solid fa-xmark"></i>
        </a>
    </div>
    <div style="margin-left: 10px;">
        #:CommentContent#
    </div>
</div>
</script>

Everything works fine, but I don't want that all users always see edit/delete buttons.

Edit button should be visible only for author and administrator, delete only for administrator.

 

Does anyone have an idea how can I do this?

Stoyan
Telerik team
 answered on 16 May 2022
1 answer
9 views

In my scheduler app i made my own editor for events, with contains most of the default inputs and some of my own. However i am having issues getting the RecurrenceEditor working. The RecurrenceEditor does showup and functions as expected in the ui, however when i submit the form after filling in an recurrence, the value in my model remains null and also doesnt throw any errors. All other inputs such as title, time, etc. does show up in my model and works as expected.

My code for the RecurrenceEditor that always submits null:

<div class="form-group">
     <div class="k-edit-label">
             @(Html.LabelFor(model => model.RecurrenceRule))
     </div>
     <div data-container-for="recurrenceRule" class="k-edit-field">
             @(Html.Kendo().RecurrenceEditorFor(model => model.RecurrenceRule)
                 .HtmlAttributes(new { data_bind = "value:recurrenceRule" }))
     </div>
</div>

An example of a input that i use and does work:

<div class="form-group">
     <div class="k-edit-label">
         @(Html.LabelFor(model => model.Description))
     </div>
     <div data-container-for="description" class="k-edit-field">
         @(Html.TextAreaFor(model => model.Description, new { @class = "k-textbox", data_bind = "value:description" }))
     </div>
</div>

 

Aleksandar
Telerik team
 answered on 16 May 2022
0 answers
2 views

Hi,

May I know, Is there any way to group scheduler by using a property that declared in the ViewModel without using and declaring resources as below?

 

@(Html.Kendo().Scheduler<Kendo.Mvc.Examples.Models.Scheduler.MeetingViewModel>()
    .Name("scheduler")
    .Date(new DateTime(2013613))
    .StartTime(new DateTime(201361370000))
    .Height(600)
    .Views(views =>
    {
        views.DayView();
        views.WeekView(weekView => weekView.Selected(true));
        views.MonthView();
        views.TimelineView();
    })

    .Timezone("Etc/UTC")

 

    .Group(group => group.Resources("RoomId"))
    
    .DataSource(d => d
            .Model(m =>
            {
                m.Id(f => f.MeetingID);
                m.Field(f => f.Title).DefaultValue("No title");
                m.RecurrenceId(f => f.RecurrenceID);
            })
            .Read("Grouping_Horizontal_Read""Scheduler")
            .Create("Grouping_Horizontal_Create""Scheduler")
            .Destroy("Grouping_Horizontal_Destroy""Scheduler")
            .Update("Grouping_Horizontal_Update""Scheduler")
    )

)

 

Thank you.

Chandrasiri


Saparamadu
Top achievements
Rank 1
 asked on 15 May 2022
0 answers
5 views

I have just updated some of my code to 2022 R2 and believe I have found a bug. It is not control specific as it is related to the DataSource and the way it generates urls.

In my code I have controllers and views within a MVC Area (Areas in ASP.NET Core | Microsoft Docs )

Up to now it worked fine and the below sample would end up generating a url that used the ambient area when generating the url

.Read(read => read.Action("Transactions_Read", "Transactions").Data("transreaddata"))

This would produce: /Admin/Transactions/Transactions_Read

Now since R2 2022 it will not use the ambient Area. Thus it will produce: /Transactions/Transactions_Read

 

Current workaround would be to add an area route value in for each url.  If one has lots of datasources where that would be necessary that could be a bit time consuming. May be classified as a breaking change

 

Doing some debugging on it with the actual telerik source code I have found the problem

In file NavigatableExtensions.cs with the function GenerateUrl (line 160)

The below was added between R1 2022 and R2 2022

 

object area;
            if (navigatable.HasValue() && navigatable.RouteValues != null && !navigatable.RouteValues.TryGetValue("area", out area))
            {
                navigatable.RouteValues.Add("area", "");
            }

Effectively, if you rely on using ambient values, you do not create a route value called "area". Thus the TryGetValue fails and causes the code to adda blank area route value which will override the ambient value

 

Chris
Top achievements
Rank 1
 asked on 14 May 2022
0 answers
4 views

I am trying to disable my edit and delete commands conditionally. I have found a couple of resources on these forums but none of them work in me scenario. I attempted to use the .Visible() function of the command cell; however, this approach is throwing an error in the browser console. So, I went a different direction and used the .Template() for my command. This is also not working because I am not getting the data item for the row in my template handler. Here is where I am at.


@(Html.Kendo().Grid<DocumentVM>()
        .Name("Documents")
        .Columns(columns =>
        {
            columns.Bound(f => f.Title)
                .ClientTemplate("<a href='" +
                    Url.Action("DisplayFile", "Documents") + "/#=Id#' target='_blank'><i class='k-icon #:FileIcon#'></i> #=Title#</a>"
                );
            columns.ForeignKey(f => f.DocumentTypesId, (System.Collections.IEnumerable)ViewData["DocTypes"], "Id", "Description");
            columns.Bound(f => f.CreatedDate).Title("Date Uploaded");
            columns.Bound(f => f.CreatedBy).Title("Uploaded By");
            columns.Command(command => {
                command.Edit().Template("#= EditableTemplate(data) #");
                command.Destroy().Template("#= DeleteTemplate(data) #");
            });
...
)


function EditableTemplate(data) {
    if (data.Editable) {
        return "<a role='button' class='k-button k-button-icontext k-grid-edit' href='#'><span class='k-icon k-i-edit'></span>Edit</a>"
    }
    else {
        return "<a role='button' class='k-button k-button-icontext k-grid-edit k-state-disabled' href='#'><span style='color: green;' class='k-icon k-i-check'></span>Edit</a>"
    }
}

function DeleteTemplate(data) {
    var currentUser = $("#CurrentUser").val();
    var userIsAdmin = $("#UserIsAdmin").val();

    if (data.Editable === true && currentUser === data.CreatedBy) {
        return "<a role='button' class='k-button k-button-icontext k-grid-delete' href='#'><span class='k-icon k-i-close'></span>Delete</a>"
    }
    else {
        return "<a role='button' class='k-button k-button-icontext k-grid-delete k-state-disabled' href='#'><span class='k-icon k-i-close'></span>Delete</a>"
    }
}
How can I access the row data item in my template handlers for commands?
Luke
Top achievements
Rank 1
 asked on 13 May 2022
Top users last month
tar
Top achievements
Rank 2
Iron
Matthias
Top achievements
Rank 5
Bronze
Bronze
Iron
Shane
Top achievements
Rank 2
Iron
Iron
Daniel
Top achievements
Rank 3
Iron
Iron
Iron
SSirica
Top achievements
Rank 2
Iron
Iron
Veteran
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?