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

Hello,

I've got a RazorPages-Project with a Grid and a Scheduler.

I'm trying to add entries to the grid inline.

The simple text fields are working as expected but when trying to save the DateTime for Start and End, always the min value of DateTime is ending up being in the Start and End fields of the model. Moreover the list of enums is not shown correctly, I also tried it with a JS function to get the list in a ClientTemplate but that didn't work for me, now it shows [object Object]. Also the DefaultValue for title property is not set correctly. This is what I got so far.

Model:

    public class VisitViewModel : ISchedulerEvent
    {
        public int Id { get; set; }

        public string? Title { get; set; } = "";

        public string? Description { get; set; } = "";

        public bool IsAllDay { get; set; } = false;

        public string? StartTimezone { get; set; } = "";

        public string? EndTimezone { get; set; } = "";

        public string? RecurrenceRule { get; set; } = "";

        public string? RecurrenceException { get; set; } = "";

        public List<Departments>? Departments { get; set; } = new List<Departments>();

        [DataType(DataType.DateTime)]
        [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd.MM.yyyy HH:mm}")]
        public DateTime Start { get; set; }

        [DateGreaterThan(OtherField = "Start")]
        [DataType(DataType.DateTime)]
        [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd.MM.yyyy HH:mm}")]
        public DateTime End { get; set; }

        public string Visitor { get; set; } = "";

        public string Company { get; set; } = "";

        public string Welcomer { get; set; } = "";
    }


Page:

@page
@model           .Pages.DetailsModel

@{
}

@using           .Data.Enum
@using           .ViewModels
@using Kendo.Mvc.UI

@inject Microsoft.AspNetCore.Antiforgery.IAntiforgery Xsrf
@Html.AntiForgeryToken()


@(
Html.Kendo().Grid<VisitViewModel>()
            .Name("grid")
            .Editable(e => e.Mode(GridEditMode.InLine))
            .Scrollable(scrollable => scrollable.Endless(true))
            .Scrollable(a => a.Height("250px"))
            .ToolBar(x => x.Create())
            .Columns(columns =>
            {
                columns.Bound(column => column.Start).Width(250).Format("{0:dd.MM.yyyy HH:mm}").EditorTemplateName("DateTime");
                columns.Bound(column => column.End).Width(250).Format("{0:dd.MM.yyyy HH:mm}").EditorTemplateName("DateTime");
                columns.Bound(column => column.Visitor).Width(250);
                columns.Bound(column => column.Company).Width(250);
                columns.Bound(column => column.Welcomer).Width(250);
                columns.Bound(column => column.Departments).EditorTemplateName("Departments");
                columns.Bound(column => column.Description);
                columns.Command(column =>
                {
                    column.Edit();
                    column.Destroy();
                }).Width(230);
            })
            .DataSource(ds => ds.Ajax()
            .Read(r => r.Url("/Details?handler=Read").Data("forgeryToken"))
            .Update(u => u.Url("/Details?handler=Update").Data("forgeryToken"))
            .Create(c => c.Url("/Details?handler=Create").Data("forgeryToken"))
            .Destroy(d => d.Url("/Details?handler=Destroy").Data("forgeryToken"))
            .Model(m =>
            {
                m.Id(id => id.Id);

                m.Field(visit => visit.Title).DefaultValue("");

                m.Field(visit => visit.Departments).DefaultValue(new List<Departments>());

                m.Field(visit => visit.StartTimezone).DefaultValue("Etc/GMT+2");
                m.Field(visit => visit.EndTimezone).DefaultValue("Etc/GMT+2");

                m.Field(visit => visit.Start).DefaultValue(DateTime.Now);
                m.Field(visit => visit.End).DefaultValue(DateTime.Now);
            })
            .PageSize(5)
            )
            .Pageable()
)
@(
Html.Kendo().Scheduler<VisitViewModel>()
            .Name("scheduler")
            .Height(700)
            .DataSource(ds =>
            {
                ds.Read(r => r.Url("/Details?handler=Read").Data("forgeryToken"));
                ds.Update(u => u.Url("/Details?handler=Update").Data("forgeryToken"));
                ds.Create(c => c.Url("/Details?handler=Create").Data("forgeryToken"));
                ds.Destroy(d => d.Url("/Details?handler=Destroy").Data("forgeryToken"));
            })
)



<script type="text/javascript">
    function forgeryToken() {
        return kendo.antiForgeryTokens();
    } 
</script>

PageModel:

public class DetailsModel : PageModel
{
    private readonly          Context _context;

    public DetailsModel(         Context context)
    {
        _context = context;
    }

    public void OnGet()
    {
    }

    public override void OnPageHandlerExecuting(PageHandlerExecutingContext context)
    {
        CultureInfo.DefaultThreadCurrentCulture = CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo("de-DE");

        base.OnPageHandlerExecuting(context);
    }

    public JsonResult OnPostRead([DataSourceRequest] DataSourceRequest request)
    {
        return new JsonResult(_context.VisitViewModels.ToDataSourceResult(request));
    }

    public JsonResult OnPostCreate([DataSourceRequest] DataSourceRequest request, VisitViewModel visit)
    {
        _context.VisitViewModels.Add(visit);
        _context.SaveChanges();

        return new JsonResult(new[] { visit }.ToDataSourceResult(request, ModelState));
    }

    public JsonResult OnPostUpdate([DataSourceRequest] DataSourceRequest request, VisitViewModel visit)
    {
        _context.VisitViewModels.Update(visit);
        _context.SaveChanges();
        return new JsonResult(new[] { visit }.ToDataSourceResult(request, ModelState));
    }

    public JsonResult OnPostDestroy([DataSourceRequest] DataSourceRequest request, VisitViewModel order)
    {
        _context.VisitViewModels.Remove(order);
        _context.SaveChanges();
        return new JsonResult(new[] { order }.ToDataSourceResult(request, ModelState));
    }
}

EditorTemplate DateTime

@model DateTime?

@(Html.Kendo().DateTimePickerFor(m => m).HtmlAttributes(new { title = Html.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName("") }).Format("{0:dd.MM.yyyy HH:mm}"))

Furthermore I have problems with the language in my project, maybe this correlates. They are mixed up as you can see in the attachment.

 

Mihaela
Telerik team
 answered on 23 Jul 2024
1 answer
70 views

Hello. i m wishing to use in future telerik ui for asp.net core for my projects.


 I use Telerik.UI.for.AspNet.Core and Telerik.Web.Spreadsheet packages for VS 2022.

Right now i'm testing in demo version realization of formulas. I made my formulas, it works good, makes the result that i want

But looks like it recalculates formula in ANY change on the sheet.  .
Its a big optimization problem cause i need a big sheet with thousands cells with this formula
Any way to avoid it?

I need to recalculate formulas only if depended cells were changed just like base formulas works, but i don't see in documentation any way to make it

Looks like whole telerik formulas works like that. any change makes rerender of sheet and recalculation of any formulas

 

Alexander
Telerik team
 answered on 23 Jul 2024
2 answers
129 views

How is it possible to add a fully functional icon button in grids Group Header ?

My approach : 

                @(Html.Kendo().Grid<ClaimViewModel>()
                    .Name("dgvClaims")
                    .Columns(columns =>
                    {
                        columns.Command(command => command.Custom("Vorgang hinzufügen").IconClass("save").Click("showDetails")).Width(300);
                        columns.Bound(p => p.Id).Filterable(false).Visible(false);
                        @* columns.Bound(p => p.ClaimId).ClientGroupHeaderTemplate(@"<div>Alfred Mustermann</div><div><button name=""textButton""  theme-color=""ThemeColor.Primary"" type=""button"" icon=""arrow-rotate-cw"" on-click=""onClick"">Add Button</button></div>"); *@
                        columns.Bound(p => p.ClaimId).ClientGroupHeaderTemplate(@"<div>
                                                                                    <div>Alfred Mustermann</div>
                                                                                    <kendo-button name=""textButton"" type=""button"" theme-color=""ThemeColor.Primary"">Add Button</kendo-button>
                                                                                  </div>");
                        columns.Bound(p => p.VnName).Width(300);
                        columns.Bound(p => p.ClaimState).Title("Status").Width(100);
                        columns.Bound(p => p.ClaimnumberInsurance).Title("Schadennummer VU").Width(150);
                        columns.Bound(p => p.ClaimnumberRisktaker).Title("Schadennummer Risikoträger").Width(150);
                        columns.Bound(p => p.ClaimFriendlyName).Title("Beschreibung").Width(200);
                        columns.Bound(p => p.ClaimDate).Title("Schadendatum").Format("{0:dd.MM.yyyy}");
                        columns.Bound(p => p.ClaimItemReference).Title("Verweis auf Mappeneintrag").Width(200);
                        columns.Bound(p => p.ClaimItemReferenceType).Title("Eintragstyp").Width(150);
                        columns.Bound(p => p.ClaimItemRemark).Title("Bemerkungen").Width(150);
                    
                    })
                    .Selectable(s => s.Mode(GridSelectionMode.Single)
                    .Type(GridSelectionType.Row))
                    .Pageable()
                    .Sortable()
                    .Scrollable()
                    .Filterable()
 
                   .HtmlAttributes(new { style = "height:650px;" })
                   .Events(events => events.Change("onChangeCustomerGrid"))
                   .DataSource(dataSource => dataSource.Ajax()

Ivaylo
Telerik team
 answered on 22 Jul 2024
1 answer
55 views

Hello,

 

Is it possible to use a Grid's built-in popup editor to display a Kendo Editor component? I'm finding some solutions that are close, but not quite exactly what I'm looking for. Basically one of the columns in the Grid has a need to allow rich HTML text when creating/editing, and the Kendo Editor seems to be the best way to do this. 

Mihaela
Telerik team
 answered on 22 Jul 2024
0 answers
83 views
I want to create a edit popup template where I want to display the 2 to 3 fields in a single row. First question:- Can I do this in the existing template.
Second question:- If I create a separate template how to pass and bind the model to the template.
Kiran
Top achievements
Rank 1
 asked on 17 Jul 2024
1 answer
99 views

For my app I ideally would like to achieve the following layout :

  • Fixed / static header with links to most commonly used areas of the app, each with expandable sub links to more specific locations
  • Left hand slide menu - ideally with some icons down the left for quick access to a section, or able to be expanded via an icon which is in the header - each section would also need to have expandable links ideally
  • Ideally a fixed / static footer, although this is less important

So am I right in thinking this is the way to go about it?

Header - this would be an app bar component,

Expandable links within the header - a menu component embedded within the app bar for the expandable links

Left bar - this would be a drawer component so it can show the icons and be expanded on demand - would this also need an embedded menu component so each section can expand?

Thanks

Anton Mironov
Telerik team
 answered on 16 Jul 2024
1 answer
59 views

So have a question as I may just not understand the difference to what I think something controls to what it actually controls. When I select the add new record it triggers the following line control:

If e.CommandName = RadGrid.UpdateCommandName Then

Additionally, the edit button also triggers the same line. Is there a way to make that button on the grid trigger one or the other, specifically the performinsertcommand or are both supposed to trigger the same command?

 

(see picture below)

 

Code headers for that grid:
<telerik:RadGrid ID="RadGrid" runat="server" AllowPaging="True" Width="800px" OnItemDataBound="RadGrid_ItemDataBound" OnNeedDataSource="RadGrid_NeedDataSource" OnItemCommand="RadGrid_ItemCommand" 
    OnItemCreated="RadGrid_ItemCreated" OnDeleteCommand="RadGrid_ItemDeleted" Skin="MetroTouch">

Vasko
Telerik team
 answered on 16 Jul 2024
2 answers
844 views

I am currently trialing the products to see if I can get them to do what I need for an app under development.

In my app I have a grid that lists all of a customers active products.

I want to be able to click on an item in the grid (link or button) to launch a modal dialog where I can display in depth info regarding that item - the popup itself would need to have tabstrip and perhaps one or two grids on itself.

So I obviously need to design a view to display all this info which is fine, and I assume the Window component is the most suitable to effect the popup?

I can't seem to find a concrete example of how to call the window from the initial grid, pass the parameter of the selected item, and then load the view within the window.

As I say I am new to all this so feeling my way a little and so any guidance is greatly appreciated.

Thanks

Alexander
Telerik team
 answered on 16 Jul 2024
1 answer
78 views

I have a grid in which I am using the columns.Select (see code below) and want a title to display next to the check box in the header where the user clicks the check box to select all rows. There is Title property but when I give it a value it does not display in the header as the other titles do.

This is what I have

 .Columns(columns =>
            {                
                columns.Bound(i => i.lotNumber).Title("Lot Number").Width(100);
                columns.Bound(i => i.lotLocation).Title("Lot Location").Width(100);
                columns.Bound(i => i.lotQuantity).Title("Lot Quantity").Width(100).ClientFooterTemplate("Total: #=sum#"); 
                columns.Bound(i => i.plannedStartDate).Title("Planned Start Date").Width(100).Format("{0:MM/dd/yyyy}");
                columns.Bound(i => i.batchDueDate).Title("Batch Due Date").Width(100).Format("{0:MM/dd/yyyy}");                  
                columns.Select().Title("Pulled").Width(100);                   
               })

Below is a screenshot of the results. I want the text Pulled next to the check box in the header.

Mihaela
Telerik team
 answered on 11 Jul 2024
1 answer
415 views

Do we need to have individual license for each developers to work on the Telerik UI for ASP NET Core. 

Note:

When other developer try to clone the code from repository which has the dependency on Telerik UI for ASP NET Core, the package was not getting restored when build/rebuild the Appliation and error was thrown instead 

Severity Code Description Project File Line Suppression State
Error NU1102 Unable to find package Telerik.UI.for.AspNet.Core with version (>= 2024.2.514)
- Found 1 version(s) in nuget.org [ Nearest version: 2016.3.914 ]
- Found 0 version(s) in Microsoft Visual Studio Offline Packages

Any assistance on this would be appreciated.

Mihaela
Telerik team
 answered on 08 Jul 2024
Narrow your results
Selected tags
Tags
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?