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

I'm having some issues with pivot grid and need some assistance. 

I'm trying to create a pivot grid that looks something like this.  It's a simple example that I would be expanding on.  It shows the total commission received from a company by year.

 I've two questions:

  • 1) Can I get the data directly from the SQL Table without going into a list
  • 2) Why is nothing showing up in the pivot grid

Right now I'm testing in Asp.Net Core .Net 6 and Telerik.UI.for.AspNet.Core 2022.1.301

The model looks like this

    public class CommRecd
    {
        public Guid Id { get; set; }
        public DateTime ReceivedDate { get; set; }
        public string? CompanyName { get; set; }
        public Decimal ReceivedAmount { get; set; }
        public int ReceivedYear { get; set; }
    }

The controller method is below and I've confirmed that objCommList contains the data

        public IActionResult PivotGrid()
        {
            IEnumerable<CommRecd> objCommList = _db.CommRecd;
            return View(objCommList);
        }

I'm basing my code on this example Remote binding in ASP.NET Core PivotGrid Component Demo | Telerik UI for ASP.NET Core with the code shown below.

@using Application.Models;
@model IEnumerable<CommRecd>
@{ ViewBag.Title = "Commission Received Report"; }
@Html.AntiForgeryToken()

<div class="k-pivotgrid-wrapper">
    @(Html.Kendo().PivotConfigurator()
        .Name("configurator")
        .HtmlAttributes(new { @class = "hidden-on-narrow" })
        .Filterable(true)
        .Sortable(true)
        .Height(570)
    )

    @(Html.Kendo().PivotGrid<CommRecd>()
        .Name("pivotgrid")
        .Configurator("#configurator")
        .ColumnWidth(120)
        .Filterable(true)
        .Height(570)
        .DataSource(dataSource => dataSource
            .Ajax()
            .Schema(schema => schema
                .Cube(cube => cube
                    .Dimensions(dimensions => {
                        dimensions.Add(model => model.CompanyName).Caption("All Companies");
                        dimensions.Add(model => model.ReceivedAmount).Caption("All Amounts");
                        dimensions.Add(model => model.ReceivedYear).Caption("All Years");
                    })
                    .Measures(measures =>
                    {
                        measures.Add("Sum").Format("{0:c}").Field(model => model.ReceivedAmount).AggregateName("sum");
                    })
                ))
            .Columns(columns =>
            {
                columns.Add("ReceivedDate").Expand(true);
            })
            .Rows(rows => rows.Add("CompanyName").Expand(true))
            .Measures(measures => measures.Values("Sum"))
            .Events(e => e.Error("onError"))
        )
    )
</div>
<div class="responsive-message"></div>

<script>
    function onError(e) {
        alert("error: " + kendo.stringify(e.errors[0]));
    }
</script>

My output looks like this


Thanks for any suggestions

 

Alexander
Telerik team
 updated answer on 22 Mar 2022
1 answer
474 views

Hey guys,

I think it is a bug because the requried validation attribute is not rendered when using tag helper. Can you validate my problem?
Kendo version: 2022.1.119

Model:

[Required(ErrorMessage = "Hey, I am an error message.")]
public string Test { get; set; }

View (working example with html helper):

@Html.Kendo().TextAreaFor(x => x.Test).Rows(3)

View (not working example with tag helper):

<kendo-textarea name="Test" rows="3"></kendo-textarea>

 

The data-val="true" data-val-required="xxx" attributes are only rendered with html helper.

Aleksandar
Telerik team
 answered on 22 Mar 2022
1 answer
179 views
Is there a way to display the Duration of a Task as a column on the left?
Aleksandar
Telerik team
 answered on 21 Mar 2022
0 answers
118 views

The user edits dates in a grid in D M Y format .. BUT when saved we see an error that indicates it is expecting M D Y format.

Please see attached files.

adamhughes
Top achievements
Rank 1
Iron
Veteran
 asked on 21 Mar 2022
2 answers
311 views

I think I'm close.  Its not throwing any errors but its also not displaying any data... Im just trying to get it to display a list of Company Names and Company IDs from my TblCompanyInfo table.

This is my controller:

        public async Task<IActionResult> Index()
            {
            var apptReminderContext = _context.TblCompanyInfos.Include(t => t.AcctType).Include(t => t.CompanyStatus).Include(t => t.OnHoldReason);
            return View(await apptReminderContext.ToListAsync());
            //return View();
        }

        public JsonResult Products_Read([DataSourceRequest] DataSourceRequest request)
        {
            DataSourceResult result = _context.TblCompanyInfos.ToDataSourceResult(request,
                model => new TblCompanyInfo
                {
                    CompanyId = model.CompanyId,
                    CompanyName = model.CompanyName
                });
            return Json(result);
        }

and my view...

@model IEnumerable<AppointmentRemindersNetCoreMVC.Models.TblCompanyInfo>

@{
    ViewData["Title"] = "Index";
}

<h1>Index</h1>

@using AppointmentRemindersNetCoreMVC.Data
@using Kendo.Mvc.UI
@addTagHelper *, Kendo.Mvc

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

       @(Html.Kendo().Grid<AppointmentRemindersNetCoreMVC.Models.TblCompanyInfo>()
        .Name("grid")
        .DataSource(dataSource => dataSource.Ajax()
        .Read(read => read.Action("Products_Read", "Company"))
        .PageSize(20)
        //.ServerOperation(false)
        //.Model(model => model.Id(c => c.CompanyId))
        //.Read("Products_Read", "Company")
        //.Read(read => read.Action("Products_Read", "Company"))
        .Update("UpdateCustomer", "Home")
        .Create("InsertCustomer", "Home")
        .Destroy("DeleteCustomer", "Home"))

        .Columns(columns =>
        {
            columns.Bound(product => product.CompanyName);
            columns.Bound(product => product.CompanyId);
        })
        .Pageable()
        .Sortable()
        
    )

I know that the Products_Read function is being called by the view and I also know that the "result" contains 32 rows of data.  However, nothing is displayed in the grid

See the attached screenshot.

Thank you for any help you can provide!!

 

Jonah
Top achievements
Rank 1
Iron
 answered on 18 Mar 2022
1 answer
530 views

Hello,

 

I have a grid for my ASP.NET Core Razor page, and have it bound to the Model object.

In the interest of saving horizontal space, and for readability, we would like to split some cells to show Start date / End date in one cell, rather than have two columns for this data.  Both data should be editable.

Is this possible?

Thanks

Aleksandar
Telerik team
 answered on 18 Mar 2022
1 answer
1.2K+ views

Good afternoon,

I've used the following to get the date filter in my Grid to use the dd/MM/yyyy format:

columns.Bound(t => t.Datestamp).Title("Date").Format("{0:dd/MM/yyyy HH:mm:ss}").Filterable(f => f.UI("datestampFilter"));
    function datestampFilter(element) {
        element.kendoDatePicker({
            format: "{0:dd/MM/yyyy}",
            parseFormats: ["dd/MM/yyyy"]
        });
    }

This works but the class of the datepicker input is incorrect and, as as result, the button is not aligned right and the border of the input is darker:

It generates an input:

<input title="Value" data-bind="value:filters[0].value" class="" type="text" data-role="datepicker" role="combobox" aria-expanded="false" aria-haspopup="grid" autocomplete="off" aria-disabled="false" aria-readonly="false">

It's missing class="k-input-inner" which is what is generated when no formatting is applied to the date column.

Have I missed something else which is causing the slightly incorrect styling?

Kind regards,

Richard

Alexander
Telerik team
 answered on 17 Mar 2022
1 answer
341 views

Is there a way to drag and drop from one ListBox to any number of other ListBoxes? I have a use case where I have a list of items and I want to be able to drag those items to any one of multiple other ListBoxes to assign them to a group. The documentation and examples show being able to drag to ony one other ListBox.  

Has anyone done this before and can point me to some example code?

 

Thank you!

Aleksandar
Telerik team
 answered on 17 Mar 2022
1 answer
446 views

I have a grid with two columns one text and one is datetime. The grid has to be edited in a popup. Because the datetime calendar is too big we want move the buttons in the popup below. So we tried to give the popup window a height. However if we do that the buttons do not stick to the bottom. They remain to where the content is finished.

How can this be achieved?

Patrick | Technical Support Engineer, Senior
Telerik team
 answered on 16 Mar 2022
1 answer
279 views
Is there a way to add a dropdown to filter events in the scheduler? I can't seem to find an example to accomplish this. Would this entail using a resource in the scheduler? I've added images of my scheduler and events. Each event is a leave request from a user and has a department id. I'd like to filter the scheduler with a drop down based on department id.
Stoyan
Telerik team
 answered on 16 Mar 2022
Narrow your results
Selected tags
Tags
+? more
Top users last month
Cynthia
Top achievements
Rank 1
Iron
Toby
Top achievements
Rank 3
Iron
Iron
Iron
Danielle
Top achievements
Rank 1
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Iron
yw
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Cynthia
Top achievements
Rank 1
Iron
Toby
Top achievements
Rank 3
Iron
Iron
Iron
Danielle
Top achievements
Rank 1
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Iron
yw
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?