Telerik Forums
UI for ASP.NET Core Forum
3 answers
1.9K+ views

I have a portal and an IdentityServer4 site for authentication.  When I load a page my Telerik Grid goes out to get the data.  My scenario is, if I let the page sit long enough to let the Token expire I expect the UI to redirect for login... but that doesn't happen.  The grid works fine when I have a valid Access Token.  I need this to redirect and be happy.  Instead, the grid returns no feedback and I get the following:

Request (I removed the cookie gook):

Invoke-WebRequest -Uri "https://localhost:44355/Customers/IndexJson" `
-Method "POST" `
-Headers @{
"method"="POST"
  "authority"="localhost:44355"
  "scheme"="https"
  "path"="/Customers/IndexJson"
  "sec-ch-ua"="`"Google Chrome`";v=`"87`", `" Not;A Brand`";v=`"99`", `"Chromium`";v=`"87`""
  "accept"="*/*"
  "x-requested-with"="XMLHttpRequest"
  "sec-ch-ua-mobile"="?0"
  "user-agent"="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36"
  "origin"="https://localhost:44355"
  "sec-fetch-site"="same-origin"
  "sec-fetch-mode"="cors"
  "sec-fetch-dest"="empty"
  "referer"="https://localhost:44355/Customers"
  "accept-encoding"="gzip, deflate, br"
  "accept-language"="en-US,en;q=0.9"
-ContentType "application/x-www-form-urlencoded; charset=UTF-8" `
-Body "sort=&page=1&pageSize=20&group=&filter=&dateRangeIndex=3&isActiveIndex=0";
Invoke-WebRequest -Uri "https://localhost:5001/connect/authorize?client_id=GsiPortal.App&redirect_uri=https%3A%2F%2Flocalhost%3A44355%2Fsignin-oidc&response_type=code&scope=openid%20profile%20offline_access%20email%20phone%20address%20roles%20IdentityServerApi%20Gsi.Activity.Api%20Gsi.Azure.Blob.Api%20Gsi.Azure.Comm.Api%20Gsi.Customer.Api%20Gsi.Cloud.Maintenance.Api&response_mode=form_post&nonce=...cleaned...-client-SKU=ID_NETSTANDARD2_0&x-client-ver=6.7.1.0" -Headers @{
"Referer"="https://localhost:44355/"
  "User-Agent"="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36"
};
Invoke-WebRequest -Uri "https://localhost:5001/connect/authorize?client_id=GsiPortal.App&redirect_uri=https%3A%2F%2Flocalhost%3A44355%2Fsignin-oidc&response_type=code&scope=openid%20profile%20offline_access%20email%20phone%20address%20roles%20IdentityServerApi%20Gsi.Activity.Api%20Gsi.Azure.Blob.Api%20Gsi.Azure.Comm.Api%20Gsi.Customer.Api%20Gsi.Cloud.Maintenance.Api&response_mode=form_post&nonce=...cleaned...-client-SKU=ID_NETSTANDARD2_0&x-client-ver=6.7.1.0" `
-Method "OPTIONS" `
-Headers @{
"method"="OPTIONS"
  "authority"="localhost:5001"
  "scheme"="https"
  "path"="/connect/authorize?client_id=GsiPortal.App&redirect_uri=https%3A%2F%2Flocalhost%3A44355%2Fsignin-oidc&response_type=code&scope=openid%20profile%20offline_access%20email%20phone%20address%20roles%20IdentityServerApi%20Gsi.Activity.Api%20Gsi.Azure.Blob.Api%20Gsi.Azure.Comm.Api%20Gsi.Customer.Api%20Gsi.Cloud.Maintenance.Api&response_mode=form_post&nonce=...cleaned...-client-SKU=ID_NETSTANDARD2_0&x-client-ver=6.7.1.0"
  "accept"="*/*"
  "access-control-request-method"="GET"
  "access-control-request-headers"="x-requested-with"
  "origin"="https://localhost:44355"
  "user-agent"="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36"
  "sec-fetch-mode"="cors"
  "sec-fetch-site"="same-site"
  "sec-fetch-dest"="empty"
  "referer"="https://localhost:44355/"
  "accept-encoding"="gzip, deflate, br"
  "accept-language"="en-US,en;q=0.9"
};
Invoke-WebRequest -Uri "https://localhost:44355/Customers/IndexJson" `
-Method "POST" `
-Headers @{
"method"="POST"
  "authority"="localhost:44355"
  "scheme"="https"
  "path"="/Customers/IndexJson"
  "sec-ch-ua"="`"Google Chrome`";v=`"87`", `" Not;A Brand`";v=`"99`", `"Chromium`";v=`"87`""
  "accept"="*/*"
  "x-requested-with"="XMLHttpRequest"
  "sec-ch-ua-mobile"="?0"
  "user-agent"="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36"
  "origin"="https://localhost:44355"
  "sec-fetch-site"="same-origin"
  "sec-fetch-mode"="cors"
  "sec-fetch-dest"="empty"
  "referer"="https://localhost:44355/Customers"
  "accept-encoding"="gzip, deflate, br"
  "accept-language"="en-US,en;q=0.9"
} `
-ContentType "application/x-www-form-urlencoded; charset=UTF-8" `
-Body "sort=&page=1&pageSize=20&group=&filter=&dateRangeIndex=3&isActiveIndex=0";
Invoke-WebRequest -Uri "https://localhost:5001/connect/authorize?client_id=GsiPortal.App&redirect_uri=https%3A%2F%2Flocalhost%3A44355%2Fsignin-oidc&response_type=code&scope=openid%20profile%20offline_access%20email%20phone%20address%20roles%20IdentityServerApi%20Gsi.Activity.Api%20Gsi.Azure.Blob.Api%20Gsi.Azure.Comm.Api%20Gsi.Customer.Api%20Gsi.Cloud.Maintenance.Api&response_mode=form_post&nonce=...cleaned...-client-SKU=ID_NETSTANDARD2_0&x-client-ver=6.7.1.0" -Headers @{
"Referer"="https://localhost:44355/"
  "User-Agent"="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36"
};
Invoke-WebRequest -Uri "https://localhost:5001/connect/authorize?client_id=GsiPortal.App&redirect_uri=https%3A%2F%2Flocalhost%3A44355%2Fsignin-oidc&response_type=code&scope=openid%20profile%20offline_access%20email%20phone%20address%20roles%20IdentityServerApi%20Gsi.Activity.Api%20Gsi.Azure.Blob.Api%20Gsi.Azure.Comm.Api%20Gsi.Customer.Api%20Gsi.Cloud.Maintenance.Api&response_mode=form_post&nonce=...cleaned...-client-SKU=ID_NETSTANDARD2_0&x-client-ver=6.7.1.0" `
-Method "OPTIONS" `
-Headers @{
"method"="OPTIONS"
  "authority"="localhost:5001"
  "scheme"="https"
  "path"="/connect/authorize?client_id=GsiPortal.App&redirect_uri=https%3A%2F%2Flocalhost%3A44355%2Fsignin-oidc&response_type=code&scope=openid%20profile%20offline_access%20email%20phone%20address%20roles%20IdentityServerApi%20Gsi.Activity.Api%20Gsi.Azure.Blob.Api%20Gsi.Azure.Comm.Api%20Gsi.Customer.Api%20Gsi.Cloud.Maintenance.Api&response_mode=form_post&nonce=...cleaned...-client-SKU=ID_NETSTANDARD2_0&x-client-ver=6.7.1.0"
  "accept"="*/*"
  "access-control-request-method"="GET"
  "access-control-request-headers"="x-requested-with"
  "origin"="https://localhost:44355"
  "user-agent"="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36"
  "sec-fetch-mode"="cors"
  "sec-fetch-site"="same-site"
  "sec-fetch-dest"="empty"
  "referer"="https://localhost:44355/"
  "accept-encoding"="gzip, deflate, br"
  "accept-language"="en-US,en;q=0.9"
}

Errors:

Customers#:1 Access to XMLHttpRequest at 'https://localhost:5001/connect/authorize?client_id=GsiPortal.App&redirect_uri=https%3A%2F%2Flocalhost%3A44355%2Fsignin-oidc&response_type=code&scope=openid%20profile%20offline_access%20email%20phone%20address%20roles%20IdentityServerApi%20Gsi.Activity.Api%20Gsi.Azure.Blob.Api%20Gsi.Azure.Comm.Api%20Gsi.Customer.Api%20Gsi.Cloud.Maintenance.Api&response_mode=form_post&nonce=637462512968208243.ZTllMzdmOGEtMzRlZS00YWZmLWExMGItNTI0NGEwMmNlYmE2MTQ5ZTIyZmMtMWQ4Yi00YWU3LTk2NTMtYTY2N2FjMzViNDkz&state=CfDJ8D424Yro--hNo8czS4g4Tz-M0hUZ8IWLi1m4T_Vf02s_0tj9j1HSSNWueJYBxRBUEaKtzsY2P5UDGqi81fSr7doRchzSEur_bDMgPj7KwjTD70DlRUhBCalBV3sz08X793e8JQTKwAp_Psp7VOeoM-XGKIpFW-flsS0Z1sHwIUusvFhkXQdvGNfWMlJ4xHMzweHEUNFqTxPkevdBetlRNnCcUExXZYArJDr2IcewGDAS0toh7L2TUWZQ3DT56aXG_18aLwRHSuNXuRzEE1c8GJMgj97cYy5mfW4QRNW9oGBFPe41dhASstz4VaVyinNEPw&x-client-SKU=ID_NETSTANDARD2_0&x-client-ver=6.7.1.0' (redirected from 'https://localhost:44355/Customers/IndexJson') from origin 'https://localhost:44355' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
jquery.min.js:4 GET https://localhost:5001/connect/authorize?client_id=GsiPortal.App&redirect_uri=https%3A%2F%2Flocalhost%3A44355%2Fsignin-oidc&response_type=code&scope=openid%20profile%20offline_access%20email%20phone%20address%20roles%20IdentityServerApi%20Gsi.Activity.Api%20Gsi.Azure.Blob.Api%20Gsi.Azure.Comm.Api%20Gsi.Customer.Api%20Gsi.Cloud.Maintenance.Api&response_mode=form_post&nonce=637462512968208243.ZTllMzdmOGEtMzRlZS00YWZmLWExMGItNTI0NGEwMmNlYmE2MTQ5ZTIyZmMtMWQ4Yi00YWU3LTk2NTMtYTY2N2FjMzViNDkz&state=CfDJ8D424Yro--hNo8czS4g4Tz-M0hUZ8IWLi1m4T_Vf02s_0tj9j1HSSNWueJYBxRBUEaKtzsY2P5UDGqi81fSr7doRchzSEur_bDMgPj7KwjTD70DlRUhBCalBV3sz08X793e8JQTKwAp_Psp7VOeoM-XGKIpFW-flsS0Z1sHwIUusvFhkXQdvGNfWMlJ4xHMzweHEUNFqTxPkevdBetlRNnCcUExXZYArJDr2IcewGDAS0toh7L2TUWZQ3DT56aXG_18aLwRHSuNXuRzEE1c8GJMgj97cYy5mfW4QRNW9oGBFPe41dhASstz4VaVyinNEPw&x-client-SKU=ID_NETSTANDARD2_0&x-client-ver=6.7.1.0 net::ERR_FAILED
send @ jquery.min.js:4
ajax @ jquery.min.js:4
read @ kendo.all.js:6404
read @ kendo.aspnetmvc.js:257
(anonymous) @ kendo.all.js:7524
_queueRequest @ kendo.all.js:7790
read @ kendo.all.js:7517
gridRefresh @ Customers:214
onclick @ Customers:171

Grid:

        @(Html.Kendo().Grid<Customer>()
            .Name("grid")
            .Columns(columns =>
            {
                columns.Command(command => command
                    .Custom("Select")
                    .Click("goDetail"))
                    .Width(Glossary.Portal.ButtonWidth);
                columns.Bound(p => p.Name)
                    .Filterable(ftb => ftb.Cell(cell => cell.Operator("contains")
                        .ShowOperators(false)
                        .SuggestionOperator(FilterType.Contains)));
                columns.Bound(p => p.LicenseRenewalTimestamp).Title("License Renewal");
            })
            .Pageable()
            .Sortable()
            .Scrollable()
            .Filterable(ftb => ftb.Mode(GridFilterMode.Row))
            .HtmlAttributes(new {style = "height:596px;"})
            .Selectable()
            .Navigatable()
            .DataSource(dataSource => dataSource
                .Ajax()
                .PageSize(20)
                .Read(read => read.Action("IndexJson", "Customers")
                    .Data("gridGetData"))))

Script:

    function gridRefresh() {
        var grid = $("#grid").getKendoGrid();
        grid.dataSource.read();
    }

    function gridGetData() {

        var isActiveIndex = $("#isActiveOptions").val();
        //alert("isActiveIndex: " + isActiveIndex);

        var dateRangeIndex = $("#dateRangeOptions").val();
        //alert("dateRangeIndex: " + dateRangeIndex);

        return {
            dateRangeIndex: dateRangeIndex,
            isActiveIndex: isActiveIndex
        };

        return null;
    }

 

Anton Mironov
Telerik team
 answered on 22 Jan 2021
4 answers
376 views

I've sorted out how to use the custom editor template but what I'd like to do is to replace the entire dialog with one that matches the look of the rest of our application.  Using the template I can replace individual controls but the header/window/button look and feel is different that what we'd like.   I know I can style them but the layout is a little different and I'd like more control.

Can I intercept and block the editor loading and load my own dialog?  Or is there another means that I can replace the edit process with my own view?

 

Thanks,

Brian

 

Petar
Telerik team
 answered on 22 Jan 2021
6 answers
707 views

Is there a way to change the width of the control. I've try htmlattribute with a class that include the width nothing is changing.

Any clue ?

Best regards

Patrick | Technical Support Engineer, Senior
Telerik team
 answered on 21 Jan 2021
2 answers
329 views

Hi,

I have the following code to create a form, but when I submit it, I get a 400.

@(Html.Kendo().Form<ConfigurationModel>()
        .Name("formExample")
        .HtmlAttributes(new { url = @Url.Action("ProductQuantity", "Reports"), method = "POST" })
        .Items(items =>
        {
            items.Add()
            .Field(f => f.SchoolProductQuantityReportSchoolId)
            .Label(l => l.Text("School:"))
            .Hint("Select a school")
              .Editor(b =>
                b.ComboBox()
                .DataTextField("Description")
                .DataValueField("Id")
                .DataSource(dataSource => dataSource
                    .ServerFiltering(true)
                    .Read(read => read.Action(actionName, "School")
                    .Data("addAntiForgeryToken")))
                );
        })

My goal here is to not use Ajax, I want a full post back the old-fashioned way.

Thanks for your help.

 
Veselin Tsvetanov
Telerik team
 answered on 21 Jan 2021
3 answers
109 views

ASP MVC Core grid with the search box enabled.  Per the docs I turned server operation to 'false' and from what I have read this should then allow searching for more that just string types.  In the below example 'PaymentType' is an enum and the search box does not work when searching for that.  It also does not work for the formatted date. 

I could change the datatypes to string but then it might break ordering columns that are DateTime types.

 

    @(Html.Kendo().Grid<B3.Services.LoanServices.LoanServiceModels.PaymentServiceModel>()
        .Name("PaymentRegisterReport")
        .DataSource(dataSource => dataSource
            .Ajax()
            .Read(read => read.Action("Payments_Read", "StandardReports", new { area = "Reports" }))
            .PageSize(1000)
            .ServerOperation(false)
        )
        .Columns(columns =>
        {
            columns.Bound(p => p.Date).Format("{0:MM/dd/yyyy}").Title("Date");
            columns.Bound(p => p.LoanName).Title("Loan Name");
            columns.Bound(p => p.PaymentType).Title("Payment Type");
            columns.Bound(p => p.CheckNumber).Title("Check Number");
            columns.Bound(p => p.Amount).Title("Amount").Format("{0:C}")
                .HtmlAttributes(new { style = "text-align: right" }).HeaderHtmlAttributes(new { style = "text-align: right" });

        })
        .Pageable()
        .Sortable()
        .Filterable()
        .HtmlAttributes(new { style = "font-size:12px" })
        .ColumnMenu()
        .ToolBar(t =>
        {
            t.Search();
            t.Excel();
        })
        .Reorderable(l => l.Columns(true))
        .Events( e =>
        {
            e.ColumnShow("saveKendoGridState");
            e.ColumnHide("saveKendoGridState");
            e.ColumnReorder("kendoGridColumnReorder");
        })
    )

 

 

Alex Hajigeorgieva
Telerik team
 answered on 21 Jan 2021
2 answers
553 views

Hi,

I'm trying to create an ASP.NET Core version 5.0 application using MVC, Telerik UI for ASP.NET Core version 2020.3.1118, and with individual user accounts (ASP.NET Identity) authentication. I need to add scaffolded items to customize the ASP.NET Identity Pages. It seems that this release of the Telerik UI for ASP.NET Core package is incompatible with scaffolded items for ASP.NET Identity Pages. The errors I get depend on which order I do things in.

Scenario 1: First I create the app (with individual user accounts authentication). Next I add the Telerik.UI.for.AspNet.Core version 2020.3.118 package using the manage NuGet packages for solution menu item. Then I attempt to add a new scaffolded item for Identity. VS2019 gives me an error message dialog box that says:

There was an error running the selected code generator: 'Package restore failed. Rolling back package changes for 'WebApplication1'.'

Scenario 2: First I create the app (with individual user accounts authentication). Next I select the context menu item to add new scaffolded item, select Identity, click Add, wait for package changes to happen, and then cancel out of adding a new scaffolded item. Then I attempt to add the Telerik.UI.for.AspNet.Core version 2020.3.118 package using the manage NuGet packages for solution menu item. That fails and I get the following in my error list:

SeverityCodeDescriptionProjectFileLineSuppression State
ErrorNU1107Version conflict detected for Microsoft.CodeAnalysis.CSharp.Workspaces. Install/reference Microsoft.CodeAnalysis.CSharp.Workspaces 3.8.0 directly to project WebApplication1 to resolve this issue. 
 WebApplication1 -> Microsoft.VisualStudio.Web.CodeGeneration.Design 5.0.1 -> Microsoft.VisualStudio.Web.CodeGenerators.Mvc 5.0.1 -> Microsoft.VisualStudio.Web.CodeGeneration 5.0.1 -> Microsoft.VisualStudio.Web.CodeGeneration.EntityFrameworkCore 5.0.1 -> Microsoft.VisualStudio.Web.CodeGeneration.Core 5.0.1 -> Microsoft.VisualStudio.Web.CodeGeneration.Templating 5.0.1 -> Microsoft.VisualStudio.Web.CodeGeneration.Utils 5.0.1 -> Microsoft.CodeAnalysis.CSharp.Workspaces (>= 3.8.0) 
 WebApplication1 -> Telerik.UI.for.AspNet.Core 2020.3.1118 -> Microsoft.CodeAnalysis 3.3.1 -> Microsoft.CodeAnalysis.CSharp.Workspaces (= 3.3.1).WebApplication1C:\Users\bmorris\source\repos\WebApplication1\WebApplication1\WebApplication1.csproj1

SeverityCodeDescriptionProjectFileLineSuppression State
ErrorPackage restore failed. Rolling back package changes for 'WebApplication1'.

It seems that scaffolded items want to use Microsoft.CodeAnalysis.CSharp.Workspaces version 3.8 and Telerik.UI.for.AspNet.Core wants to use version 3.3.1 and the version are incompatible. Do you have a solution for this now or on the horizon?

Thanks.

Misho
Telerik team
 answered on 20 Jan 2021
1 answer
414 views

     Hi,

I have a treeview and a grid side by side on a page with bootstrap 4 layout. When the user selects a node in the treeview, the grid datasource refreshes. This works ok.

Now I'd like to size the grid and the treeview dynamically to the size of the browser window minus the header of the page, so that the treeview and the grid display a scrollbar (if needed) independently. The tree is load on demand and can contain a lot of elements.

Im struggling with setting the treeview and the grid height in the window resize handler.

Currently the grid is not paging, it maybe a requirement to have the grid paging then I would have to set the pagesize dynamically to display as much rows as possible within the available space..

Thanks for your help

 

Erwin

Martin
Telerik team
 answered on 19 Jan 2021
2 answers
107 views

Hi Experts,

I'm loading data from a DB and want to begin placing it at row 7...is this possible?

Plamen
Telerik team
 answered on 18 Jan 2021
13 answers
3.3K+ views

I am trying to figure out how i can add an action event to my custom toolbar button in the .net core grid.  I noticed that both the PDF and excel options have an available .ProxyUrl property but custom toolbar does not.

 

I have something like this......

.Toolbar(toolbar=>toolbar.Custom().Text("CSV Export")

 

I did see that something like this could be done, but that does not give me the same look and feel.  It essentially looks like a hyperlink and nothing more...

toolbar.ClientTemplate("<a href='" +Url.Action("ProductCreate", "Product") +"/test' " + ">Add product</a>");

 

Viktor Tachev
Telerik team
 answered on 14 Jan 2021
4 answers
100 views

I have a grid that has the following code as the update action in its datasource.

This is being called before the grid is rendered so I get an error that the datasource is null. Meaning I dont think the grid has initialized on the front end so the '#Grid' isnt there for the returnDirtyFields method to get. Why is this update action data method being run when the grid is not updating?

The .Data() method I want with the update action below it.

function returnDirtyFields(gridId) {
      var id = '#' + gridId;
      var dataSource;
      var data;
      var changedModels;
 
      dataSource = $(id).data("kendoGrid").dataSource;
      data = dataSource.data();
 
          if (dataSource.hasChanges()) {
          for (var i = 0; i < data.length; i++) {
 
              if (data[i].dirty) {
                  changedModels = data[i].dirtyFields
              }
              }
           }
 
      var temp = $.extend(true, {}, { dirtyFields: JSON.stringify(changedModels) });
      return temp;
  }

 

.Update(update => update.Action("Entry_Update","Entry").Data("returnDirtyFields('Grid')"))
Dan
Top achievements
Rank 1
Veteran
 answered on 13 Jan 2021
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?