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

Hi

I have this code in ASP.NET to bind a data grid to a data source returned from EF:

 

Code:

--------

        @(Html.Kendo().Grid<GarageBookingApp.Models.AdminViewModel>().Name("grid")
                        .Groupable()
                        .Sortable()
                        .Editable()
                        .Scrollable()
                        .ToolBar(x => x.Create())
                        .Columns(columns =>
                        {
                            columns.Bound(column => column.businessTimes.opening);
                            columns.Bound(column => column.businessTimes.closing);
                        
                            columns.Command(column =>
                            {
                                column.Edit();
                                column.Destroy();
                            }).Width(230);
                        })
                        .DataSource(ds => ds.Ajax()
                                .Read(r => r.Action("GetBusinessTimes", "Home"))
                            .PageSize(10)
                        )
                        .Pageable()
        )

 

The controller method is like this:

            using (GarageContext gtx = new GarageContext())
            {
                return gtx.BusinessTimes.Select(businessTimes => new BusinessTimesEntity
                {
                    closing = businessTimes.closing,
                    opening = businessTimes.opening

                }).ToList();

 

I also notice that in the model, the properties are only "getted" but not set".

 

What am I missing to retrieve the database fields correctly here?

Nikolay
Telerik team
 answered on 20 Nov 2019
2 answers
999 views

I cannot appear to install .net core mvc asp.net for the .net core 3.1 run-time is there a known issue with this yet.

All The logs I have are  the  .net version is 

Visaual Studio 16.4.0 preview 5.0

And they are a dotnetcore 3.1 project web mvc

 

Restoring packages for D:\GitMaster\Freelancer\SalesOrders\RoundTableErpAuth\RoundTableErp.Web\RoundTableErp.Web.csproj...
NU1608: Detected package version outside of dependency constraint: Microsoft.CodeAnalysis 3.3.1 requires Microsoft.CodeAnalysis.CSharp.Workspaces (= 3.3.1) but version Microsoft.CodeAnalysis.CSharp.Workspaces 3.4.0-beta4-final was resolved.
NU1701: Package 'DapperExtensions 1.6.3' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETCoreApp,Version=v3.1'. This package may not be fully compatible with your project.
NU1107: Version conflict detected for Microsoft.CodeAnalysis.Common. Install/reference Microsoft.CodeAnalysis.Common 3.4.0-beta4-final directly to project RoundTableErp.Web to resolve this issue. 
 RoundTableErp.Web -> Microsoft.CodeAnalysis.CSharp.Workspaces 3.4.0-beta4-final -> Microsoft.CodeAnalysis.Common (= 3.4.0-beta4-final) 
 RoundTableErp.Web -> Telerik.UI.for.AspNet.Core 2019.3.1023 -> Microsoft.CodeAnalysis 3.3.1 -> Microsoft.CodeAnalysis.VisualBasic.Workspaces 3.3.1 -> Microsoft.CodeAnalysis.Common (= 3.3.1).
Package restore failed. Rolling back package changes for 'RoundTableErp.Web'.
Time Elapsed: 00:00:00.9141745
========== Finished ==========

 

Petar
Telerik team
 answered on 20 Nov 2019
3 answers
374 views

I think it involves the classes .k-link k-menu-link but also hover text.  Im wanting to change both.

Anyone got any snippets for this?

 

BitShift
Top achievements
Rank 1
Veteran
 answered on 20 Nov 2019
3 answers
504 views

HI

Why the Grid read action (include javascript grid.dataSource.read() function use "api" url ???

ERROR : POST http://localhost:31466/api/AppM010/GetSomeList 415 (Unsupported Media Type)

View

.Read(read => read.Action("GetSomeList", "AppM010").Data("..."))

Javascript

grid.dataSource.read() 

There have Controller/ApiController with the same class/method name and different namespace in application : 

  namespace App1.ApiControllers
  {
    [ApiController]
    [ProducesAttribute("application/json"]
    [Route("api/{controller}/{action}")]
    public class AppM010Controller : BaseController
    {
        public AppM010Controller()
        {
        }

        [HttpPost]
        public IList<TSomeView> GetSomeList(...)
        {

  namespace App1.Controllers
  {
    public class AppM010Controller : Controller
    {
        public AppM010Controller()
        {
        }

        public ActionResult GetSomeList([DataSourceRequest]DataSourceRequest request, ...)
        {


*Don't ask me change the Controller/ApiController or method name.

Nobody knows there have the [ApiController] attribute for ApiController ?? 
I don't want any component action use the ApiController.

I think the component action got the wrong controller via action name only.
Not only the Grid, othere component is the same.

Fix this BUG as soon as possible, please.

Best regards

Chris

 

 


Boyan Dimitrov
Telerik team
 answered on 19 Nov 2019
7 answers
133 views

I'm attempting to add multiple partial views based on the click of a button. I have various controls including a date/time picker.  This works with the initial page loaded instance (index 0) however once I try to add the 2nd (index 1) from an AJAX call, the controls render but not with the Kendo UI front.  Attached file is a screen shot of the result when a new instance of the partial view is added.  What am I doing wrong that they will not render with the Kendo front?

Partial View:

<div class="col-12 col-md-3 col-lg-3 col-xl-3 order-1">
    <kendo-datetimepicker id="MyCollection[@Model.CollectionIndex].StartDateTime" format="{0:g}" class="w-100" />
</div>

 

Controller:

public PartialViewResult SplitTime(int newIndex)
        {
            return PartialView("_TimeRow", new MyModel() { CollectionIndex = newIndex });
        }
Viktor Tachev
Telerik team
 answered on 19 Nov 2019
14 answers
163 views

Hello,

When extension ASP.NET Core VSExtensions (2019.1.403.1) is installed and active, VS2019 hangs when started from JumpList (rightclick on the vs shortcut in the Taskbar). The only option left is to kill the process.

This problems sometimes occurs when solution is opened from the new start screen, but it happens less frequently.

When disabling the extension, everything is working fine.

Nikolay Mishev
Telerik team
 answered on 19 Nov 2019
7 answers
774 views

Just an FYI for anyone who encounters the same issue i did.

 

I wanted to use Telerik UI for .Net Core however in VS2019, only the MVC options were available.

 

I checked the Progress Installer, but the option to enable VS2019 support was disabled in the Progress Installer.

The info tooltip says: "Requires Microsoft Visual Studio 2019 with .net core cross-platform development workload"

So I reran the VS Installer, but I had already installed the .net core cross-platform workload previously.

 

After googling and finding nothing online, I tried the VS installer again. I checked individual components.

I saw that core 3 sdk wasn't selected. I added that and scrolled through the full list looking for anything that may have to do with the latest .net core framework and web development.

After that was done, the Progress Installer option to support VS 2019 was available.

 

So if you have a similar issue, check the individual components tab on the VS installer.

Thanks,

Bruce

Yana
Telerik team
 answered on 19 Nov 2019
4 answers
804 views

Using EF Core 3.0 and Telerik Version 2019.3.1023.

Several controls are throwing exceptions from the toDataSourceResult Method on IQueryable Types.

These queries all worked on EF Core 2.2

example 1. Has filtering on the name fields from a kendo autocomplete

The LINQ expression 'Where, Person>>( source: OrderBy, Person>, string>( source: LeftJoin, Person, Nullable, TransparentIdentifier, Person>>( outer: Join>( outer: DbSet, inner: DbSet, outerKeySelector: (u) => u.UserInfoId, innerKeySelector: (u0) => u0.UserInfoId, resultSelector: (u, u0) => new TransparentIdentifier( Outer = u, Inner = u0 )), inner: DbSet, outerKeySelector: (ti) => ti.Outer.PersonId, innerKeySelector: (p) => (Nullable)p.PersonId, resultSelector: (ti, p) => new TransparentIdentifier, Person>( Outer = ti, Inner = p )), keySelector: (ti0) => ti0.Outer.Outer.LastName), predicate: (ti0) => Format( format: "{0}, {1}", arg0: ti0.Outer.Outer.LastName, arg1: ti0.Outer.Outer.FirstName).ToLower().Contains("powell"))' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to either AsEnumerable(), AsAsyncEnumerable(), ToList(), or ToListAsync(). See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.
public JsonResult GetUsers([DataSourceRequest]DataSourceRequest request)
        {
            try
            {
                IQueryable<UserInfoViewModel> model = UserInfoListQuery.Get((SecurityEntities)this.DbContext);
                DataSourceResult result = model.ToDataSourceResult(request);
                return Json(new DataSourceResult { Data = result.Data, Errors = null, Total = result.Total });
            }
            catch (Exception ex)
            {
                 
            }
        }

public static IQueryable<UserInfoViewModel> Get(SecurityEntities ctx, Nullable<bool> showAuthorized, Nullable<bool> showEmployees)

{

users = (from ui in ctx.UserInfo
                         join us in ctx.UserInfoStatistic on ui.UserInfoId equals us.UserInfoId
                         join p in ctx.Person on ui.PersonId equals p.PersonId into people
                         from person in people.DefaultIfEmpty()
                         orderby ui.LastName
                         select new UserInfoViewModel()
                         {                     
                             FirstName = ui.FirstName,
                             LastName = ui.LastName,                           
                         });

return users;

}

 

Example 2. has kendo grid inital sorting on a DateTime that was converted to a string

The LINQ expression 'OrderByDescending( source: Where( source: DbSet, predicate: (a) => a.UserInfoId == (Unhandled parameter: __userInfoId_0)), keySelector: (a) => a.RecordModifiedDateTime.ToString("g"))' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to either AsEnumerable(), AsAsyncEnumerable(), ToList(), or ToListAsync(). See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.
public static IQueryable<AuthenticationLogViewModel> GetAuthenticationLogForUser(SecurityEntities ctx, int userInfoId)
        {
 return (from al in ctx.AuthenticationLog
                    where al.UserInfoId == userInfoId
                    orderby al.RecordModifiedDateTime descending
                    select new AuthenticationLogViewModel()
                    {                      
                        ModifiedDate = al.RecordModifiedDateTime.ToString("g"),
                    }
}

 

public JsonResult GetAuthenticationLogForUser([DataSourceRequest]DataSourceRequest request, int userInfoId)
        {
            try
            {
                IQueryable<AuthenticationLogViewModel> model = AuthenticationLogQuery.GetAuthenticationLogForUser((SecurityEntities)this.DbContext, userInfoId);
                DataSourceResult result = model.ToDataSourceResult(request);
                return Json(new DataSourceResult { Data = result.Data, Errors = false, Total = result.Total });
            }
            catch (Exception ex)
            {              
            }
        }

 

 

Ianko
Telerik team
 answered on 19 Nov 2019
1 answer
90 views

In CSHTML page, I am able to display the icon image that is in SVG.

<svg class="em-c-btn__icon " data-em-icon-path="dist/unity-1.1.0/images/em-icons.svg">
         <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="dist/unity-1.1.0/images/em-icons.svg#icon-link"></use>
</svg>

However, it is not being displayed when it is bounded to Template column in Grid. 

Code for CSHTML

@(Html.Kendo().Grid<UserModel>()
        .Name("Grid")
        .Columns(columns =>
        { columns.Template("#=actionTemplate(data)#").Title("Actions").Media("(min-width: 450px"); })))

<script id="action-template" type="text/x-kendo-template">
    <svg class="em-c-btn__icon " data-em-icon-path="dist/unity-1.1.0/images/em-icons.svg">
            <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="dist/unity-1.1.0/images/em-icons.svg#icon-link"></use>
        </svg>
</script>

<script>
    var actionTemplate = kendo.template($("#action-template").html());
</script>

Please advise

Petar
Telerik team
 answered on 18 Nov 2019
3 answers
227 views

Hello. I am trying to create the below inside a Grid.

                     <div class="btn-group">
                                        <button data-toggle="dropdown" class="btn btn-outline-dark btn-sm"><i class="fa fa-ellipsis-h"></i></button>
                                        <ul class="dropdown-menu">
                                            <li><a class="dropdown-item" asp-page="./Details" asp-route-id="@item.ID"><i class="fa fa-eye"></i> Details</a></li>
                                            @if ((await AuthorizationService.AuthorizeAsync(
                                                  User, item,
                                                  PaymentOperations.Update)).Succeeded)
                                            {
                                                <li><a class="dropdown-item" asp-page="./Edit" asp-route-id="@item.ID"><i class="fa fa-pencil"></i> Edit</a></li>
                                            }
                                            @if ((await AuthorizationService.AuthorizeAsync(
                                                User, item,
                                                PaymentOperations.Delete)).Succeeded)
                                            {
                                                <li><a class="dropdown-item" asp-page="./Delete" asp-route-id="@item.ID"><i class="fa fa-trash"></i> Delete</a></li>
                                            }
                                            </ul>
                                    </div>

Sample Code will be much appreciated.

Regards.

Alex Hajigeorgieva
Telerik team
 answered on 18 Nov 2019
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
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?