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

Hi,

I can use a ParentGrid Value in a Childgrid if I set the DefaultValue in the model to the TemplateField

     .Model(model => {
       model.Id(p => p.ALIASQLF);
       model.Field(f=> f.ALIASQLF).DefaultValue("#=ALIASQLF#"); //is a field in the parentgrid and will be set at new row
     })

 

But once I try to use a DateTime Value from the ParentGrid this approach does no longer work, as the Field expects a C# DateTime Value

Okay, just convert the Value to DateTime, right?

But the "#=FieldName#" Syntax does not seem to work as a parameter in a C# method

For Example, the following code will try to convert literally "#=ReplicationDateString#" instead of the datetime-string value:

.Model(model => {

  model.Id(p => p.ReplicationDate);
  model.Id(p=> p.VS_Jobnumber);
  model.Field(f => f.ReplicationDate).DefaultValue(DateTime.ParseExact("#=ReplicationDateString#", "yyyy-MM-dd", CultureInfo.InvariantCulture));
})

 

Then just convert it within kendo, aight?

.Model(model => {

  model.Id(p => p.ReplicationDate);
  model.Id(p=> p.VS_Jobnumber);
  model.Field(f => f.ReplicationDate).DefaultValue("#= kendo.parseDate("2022-02-02") #");
})

But the kendo.parseDate function always returns a string, so this did not work either, as it expects a C# DateTime.

 

Has anyone an Idea how to solve this problem? Is there a better approach?

Aleksandar
Telerik team
 answered on 16 Dec 2022
1 answer
87 views

Hi,

I'm currently migrating an MVC 5 project to .NET 6 and I'm having some issues with some of the extensions methods usedin MVC5 due to some classes being deprecated.

Previously we were setting someclasses on the row using a couple of extension methods:

C# Extension method


        public static void HighlightRows<T>(this GridRow<T> row, IEnumerable<Tuple<Func<T, bool>, string>> expressions)
            where T : VM
        {
            var classes = new List<string>();
            foreach (var expression in expressions)
            {
                if (expression.Item1(row.DataItem))
                {
                    if (!String.IsNullOrEmpty(expression.Item2) && classes.Count == 0)
                        classes.Add(expression.Item2);
                }
            }
            if (classes.Count > 0)
                row.HtmlAttributes["class"] = String.Join(" ", classes);
        }

And usage:

 


        @(Html.Kendo().Grid(Model.Entities)
            .Name("grid")
            .Columns(columns =>
            {
                columns.Bound(c => c.Name);
                columns.Bound(c => c.Status);
            })
            .RowAction(r =>
            {
                r.HighlightRow(new[]
                {
// if status is complete then set row class to success(set background togreen) is status is error set background to red basically.
                    Tuple.Create<Func<MyVm, bool>, string, string>(m => m.Status == "Complete, "success class"),
                    Tuple.Create<Func<MyVm, bool>, string, string>(m => m.Status == "Error", "errorclass"),
                });
            })
The issue is GridRow seems to be deprecated in ASP NET Core. I've seen some sugestions to do it client side but I'd like to keep it server side(and extension methods) ifpossible.

Is there a migration guide from MVC5 to ASP.NET Core  regarding the telerik packages or some list with what was deprecated? What's deprecated, what to use in the new version etc ?
Stoyan
Telerik team
 answered on 15 Dec 2022
1 answer
234 views

I am using Kendo ASP.NET Core and have a grid which has popup editor using custom editor template.  I am doing some password complexity validation.

I want the validator fire on keyup.   It currently only fires on blur but this is not a good user experience.   The user will think they have not succeeded unless they blur.     

How can I achieve this?  Here is my validator.

 $.extend(true, kendo.ui.validator, {
            rules: { // custom rules
                passwordcomplexity: function (input, params) {
                    if (input.is("[name='Password']") && input.val() != "") {
                        return /^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@@$%^&*-]).{6,}$/.test(input.val());
                    }
                     return true;
                },
                verifyPasswords: function(input){
                    if (input.is("[name='PasswordConfirmation']")) {
                        return input.val() === $("#Password").val();
                    }
                    return true;
                }       
            },
            messages:{
                 passwordcomplexity: function(input) {
                     return setPasswordComplexityMessage(input);
                 },
                 verifyPasswords: "Passwords do not match."
            }
        });


Stoyan
Telerik team
 answered on 15 Dec 2022
1 answer
110 views

is there a preferred method to install the .net core MVC controls when you are building and deploying through a Dockerized container?  I haven't found a tutorial to bring the controls into the build easily.

  • .net6 (core)
  • Telerik core MVC controls
  • Docker Image - mcr.microsoft.com/dotnet/sdk:6.0 AS build-env
Mihaela
Telerik team
 answered on 15 Dec 2022
1 answer
143 views

I am using Telerik 2021.1.422

I get a successful response using my url /shuttlelocation/get 

{"data":[{"accountId":933080580393897320,"routeLocationId":"26bcb4b3-0226-4de3-9e65-de878ade40e8","name":"Nelspruit","address1":"Address 1","address2":"Address 2","address3":"Address 3","address4":"Address 4","latitude":1000,"longitude":2000,"isActive":true,"createdOn":"2022-12-09T15:14:37.133289+02:00","userId":"972c57b3-2996-43f2-9336-890750dfa7f8","userName":"Anton Swanevelder"},{"accountId":933080580393897320,"routeLocationId":"0f9b89c2-4bcc-4744-a833-29a615e07417","name":"Potchefstroom","address1":"Potchefstroom","address2":"Bult","address3":"Shell Garage","address4":null,"latitude":1000.00,"longitude":2000.00,"isActive":true,"createdOn":"0001-01-01T00:00:00+00:00","userId":"972c57b3-2996-43f2-9336-890750dfa7f8","userName":"Anton Swanevelder"}],"total":2,"aggregateResults":null,"errors":null}

But my grid remain empty

There are no errors in the browser

Here is the Controller Get. The Repository returns an IQueryable

public JsonResult Get([DataSourceRequest] DataSourceRequest request)
    {
        var data = _routeLocations.GetLocationsBySearch(string.Empty);
        return this.Json(data.ToDataSourceResult(request));
    }

Here is the View

@(Html.Kendo().Grid<RouteLocationModel>()
        .Name("grid")
        .Columns(c => {
            c.Bound(p => p.Name);
            c.Bound(p => p.Address1);
            c.Bound(p => p.Latitude);
            c.Bound(p => p.IsActive);
            c.Command(c =>
            {
                c.Edit(); // The "edit" command will edit and update data items.
                c.Destroy(); // The "destroy" command removes data items.
            }).Title("Commands").Width(200);
        })
        .ToolBar(toolbar => toolbar.Create().Text("Add Location").HtmlAttributes(new { @class="" }))
        .Editable(editable => editable.Mode(GridEditMode.PopUp))
        .DataSource(d => d
            .Ajax()
            .Read(r => r.Action("Get", "ShuttleLocation"))
            .PageSize(50)
            .Model(model => {
                model.Id(p => p.RouteLocationId);
            })
        )
        .Pageable()
        .Sortable()
        .Filterable()
    )

Mihaela
Telerik team
 answered on 14 Dec 2022
1 answer
1.5K+ views

I would like to implement the ASP.NET .NET Core Grid using the pop-up editor.  The default UI produced by the popup is less than ideal though, as I have complex screens in certain cases.  I would love to implement the Form control as part of the grid declaration (DevExpress does this, for example, here:  https://demos.devexpress.com/ASPNetCore/Demo/DataGrid/PopupEditing/ - Is there something similar in the Telerik setup?  If so, is there an example?

I know I can implement templates as part of the grid, but this functionality seems odd because I have to store 50+ partial screens in  Shared/EditorTemplates folder.  Is there a better approach?  I am using Razor pages, not MVC.

Thank you,
Alex

 

Aleksandar
Telerik team
 answered on 14 Dec 2022
1 answer
128 views
We have a Python Flask app on another server that we would like to open in one of the panes in split view, is that possible?
Stoyan
Telerik team
 answered on 13 Dec 2022
1 answer
94 views


Scenario:

I've got several Line Charts in my TabStrip,

and I set these Line Charts with same Class Name by .HtmlAttributes(new {@class = "MyClass"})

I'm trying to set these Charts categoryAxis.baseUnit with JavaScript.

Question:

I get all the Line Chart with ClassName

and used a for loop to get the KendoChart and set the categoryAxis.baseUnit.

There's no error poping out,

but there was only one chart been set,

the others remains the origin setting.

I'll leave my code below hope someone could give me some hint.

Code:

.cshtml line chart

//I only showed one of the Line Chart, incase the view gets messy

@(Html.Kendo().Chart(MyViewModel) .Name("Chart1") .Title("Displacement Time History") .Legend(legend => legend .Position(ChartLegendPosition.Bottom) ) .ChartArea(chartArea => chartArea .Background("transparent") ) .SeriesDefaults(seriesDefaults => seriesDefaults.Line().Style(ChartSeriesStyle.Smooth) ) .Series(series => { series.Line(model => model.ReadData).Name("Displacement").Markers(m => m.Visible(true)); }) .ValueAxis(axis => axis .Numeric()//.Labels(labels => labels.Format("{0:n1}")) ) .CategoryAxis(axis => axis .Categories( m => m.ReadTime) .Type(ChartCategoryAxisType.Date) .BaseUnit(ChartAxisBaseUnit.Fit) .Justify(true) .Labels(labels => labels.Rotation(-90).Step(10)) .Crosshair(c => c.Visible(true)) .MajorGridLines(c => c.Visible(false)) .AutoBaseUnitSteps(config => config.Seconds(10)) ) .Tooltip(tooltip => tooltip .Visible(true) .Format("{0:n3}") ) .HtmlAttributes(new {@class = "MyChartClassName"}) // Where I set the ClassName of Chart )

javascript


$( document ).ready(function() {
        
        var chartsEle = document.getElementsByClassName('MyChartClassName'); //Gets all the HtmlDocument by ClassName
        
        // for to loop through every Line Chart
        for(var i=0; i<chartsEle.length; i++){
            
            var chart = $('#'+chartsEle[0].id).data("kendoChart"); //gets the exact KendoChart with id 
            chart.options.categoryAxis.baseUnit  = "seconds";  // setting baseUnit
            chart.redraw();
        }
      
    });

Mihaela
Telerik team
 answered on 13 Dec 2022
0 answers
113 views
Is there a way to configure the FileManager so it displays files in the grid view only? I do see how to remove the option to switch between views but if I use that it only displays files in the list view.
John
Top achievements
Rank 1
 asked on 12 Dec 2022
1 answer
148 views

We have websites using different versions of ASP.NET Core. Where can I find which versions of ASP.NET Core are supported by each release of Telerik UI for ASP.NET Core?

Thanks

Aleksandar
Telerik team
 answered on 12 Dec 2022
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?