Telerik Forums
UI for Blazor Forum
1 answer
190 views

Hi.

 

Trying to use virtualization in the Combobox with a remote data source, but the DataSourceRequest.Page in OnRead is always 0.
How to fix that?

Hristian Stefanov
Telerik team
 answered on 17 Dec 2021
1 answer
713 views

Hi

I have a question about the Upload Component. Is it possible to Upload without using a controller? I have a referenced dll that can handle the Data and pass also the Files directly, without going through a controller?!

 

Is there a way to achieve this?

 

Thanks in Advance

Best Regards

Besir

Marin Bratanov
Telerik team
 answered on 16 Dec 2021
1 answer
540 views

Hi,

is it posssible to add an image or razor component to each of the DropDown or ComboBox list items? 

And if so how?

Thanks.

Marin Bratanov
Telerik team
 answered on 16 Dec 2021
0 answers
176 views

I am using latest, edge, chrome and firefox

If I enable navigation in the grid, page up/down stops to work.

I can navigate the cells with the arrows keys, but unable to move up / down page by page.

So for now I have disabled navigation.

 

Martin Herløv
Top achievements
Rank 2
Bronze
Iron
Iron
 asked on 16 Dec 2021
1 answer
426 views

I can't find a 'k' class to make my TelerikButton look like the Bootstrap "danger" button. And if I use 'btn btn-danger' for the Class property of my TelerikButton that doesnt work either.

Is there a "k" class to do this or do I need to clear out the built in TelerikButton style somehow and write my own?

Svetoslav Dimitrov
Telerik team
 answered on 16 Dec 2021
1 answer
1.6K+ views

Hi, I try tu use the new Date/TimeOnly types of .Net6 and they are not supported by the Telerik components (you cannot bind them to these types). I tested it on the 2.30.0 version you just released.

It works fine with the Blazor Components (InputDate, input type="time"...) but it is not a practical solution for component like TelerikGrid (it would mean templating everything, breaking the inline validation etc.) or TelerikScheduler/Gantt (I would like to use a DateOnly for its Date property for example, and ideally its model could be a DateOnly and 2 TimeOnly instead of 2 DateTime but that's less important).

 

Do you have an ETA for their support or a workaround?

Also, is there documentation about the limitations of your .Net6 support so I don't have other bad surprises?

Svetoslav Dimitrov
Telerik team
 answered on 14 Dec 2021
0 answers
376 views

Hi I have made a utility class for helping with state management


<TelerikButton OnClick="@_gridStateManager.SaveState" Icon="download">Save State</TelerikButton>
<TelerikButton OnClick="@_gridStateManager.LoadState" Icon="upload">Load State</TelerikButton>
<TelerikButton OnClick="@_gridStateManager.ResetState" Icon="reset">Reset State</TelerikButton>

In the code behind file


 protected override async Task OnInitializedAsync()
{
     _gridStateManager = new GridStateManager<PortfolioListItem>(LocalStorage, PortfolioListGrid, GetDefaultGridState);
}

The problem is that the GridStateManger gets a null reference to the grid.

I know that the @ref is only safe to get in OnAfterRender / Async. How can I initialize the GridStateManager with the @ref set and also make it possible for the grid to call :


OnStateInit="@((GridStateEventArgs<PortfolioListItem> args) => _gridStateManager.OnStateInitHandler(args))">

In a safe way?

This is the code for my GridStateManager


using System;
using System.Threading.Tasks;
using Blazored.LocalStorage;
using Telerik.Blazor.Components;

namespace Argus.Client;

public class GridStateManager<T> where T : class
{
    private readonly ILocalStorageService _localStorage;
    private readonly TelerikGrid<T> _grid;
    private readonly Func<GridState<T>> _getDefaultGridState;
    private readonly string _stateStorageKey;

    public GridStateManager(
        ILocalStorageService localStorage,
        TelerikGrid<T> grid,
        Func<GridState<T>> getDefaultGridState)
    {
        _localStorage = localStorage;
        _grid = grid;
        _getDefaultGridState = getDefaultGridState;
        _stateStorageKey = $"GridStateFor{nameof(T)}";
    }

    public async Task OnStateInitHandler(GridStateEventArgs<T> args)
    {
        try
        {
            var storageState = await _localStorage.GetItemAsync<GridState<T>>(_stateStorageKey);
            if (storageState != null)
                args.GridState = storageState;
            if (storageState == null && _getDefaultGridState != null)
                args.GridState = _getDefaultGridState();
        }
        catch (Exception e)
        {
            Console.WriteLine(e);
        }
    }

    public async Task SaveState()
    {
        var gridState = _grid.GetState();
        await _localStorage.SetItemAsync(_stateStorageKey, gridState);
    }

    public async Task LoadState()
    {
        GridState<T> storedState = await _localStorage.GetItemAsync<GridState<T>>(_stateStorageKey);
        if (storedState != null)
        {
            await _grid.SetState(storedState);
        }
    }

    public async void ResetState()
    {
        if (_getDefaultGridState != null)
        {
            await _grid.SetState(_getDefaultGridState());
        }
        await _localStorage.RemoveItemAsync(_stateStorageKey);
    }
}


If I could get the grid reference in the OnStateInit  EventCallBack then I would have solved the problem

OnStateInit="@((GridStateEventArgs<PortfolioListItem> args) => _gridStateManager.OnStateInitHandler(args, @gridRef))">

 

I then tried to create the GridStateManger in the OnStateInit call from the grid. But I still don't have a valid ref to the grid, why?


OnStateInit="@((GridStateEventArgs<PortfolioListItem> args) => InitGridStateManager(args))">


private async Task InitGridStateManager(GridStateEventArgs<PortfolioListItem> args)
{
       _gridStateManager = new GridStateManager<PortfolioListItem>(LocalStorage, PortfolioListGrid, GetDefaultGridState);
       await _gridStateManager.OnStateInitHandler(args);
 }

 

Martin Herløv
Top achievements
Rank 2
Bronze
Iron
Iron
 updated question on 13 Dec 2021
0 answers
146 views

Currently I have nine service classes in this, my first Blazor app (.Net 6). Each service contains the usual async Tasks required for CRUD, eg GetStudyFees, CreateStudyFee, UpdateStudyFee. So, since this is a data intensive intranet app, which is I believe considered just the thing Blazor Server is good for, in each service I need a connection string ( I'm using Dapper), and I need the current user name, since we want to save CreatedBy and ModifiedBy.

This is how I've set this up for one service:

        

private readonly string _conn; private readonly AuthenticationStateProvider _auth; public StudyFeeService(IConfiguration config, AuthenticationStateProvider auth) { _conn = config.GetConnectionString("PharmCTConn"); _auth = auth; } public async Task<string> GetUser() { var authState = await _auth.GetAuthenticationStateAsync(); var user = authState.User; return user.Identity.Name; }

public async Task<bool> CreateStudyFee(StudyFeeViewModel studyFee) { var parameters = new DynamicParameters(); studyFee.CreatedBy = await GetUser(); parameters.AddDynamicParams(new { studyFee.HREC, studyFee.Fee, studyFee.CreatedBy }); using (var conn = new SqlConnection(_conn)) { string query = @"insert into dbo.StudyFee (HREC, Fee, CreatedBy) values (@HREC, @Fee, @CreatedBy)"; await conn.ExecuteAsync(query, parameters, commandType: CommandType.Text); } return true; }


I could duplicate this code at the top of each of my service classes, but instead is there a way that the GetUser Task could be run in Program.cs perhaps, making the username then available by injection for all services to access? I have read quite a bit around this, including StackOverflow, but being inexperienced both with Blazor and .Net Core, I haven't been able to work it out. The app will only open once the user has logged in using Windows Authentication - there is no anonymous user.
Antony
Top achievements
Rank 1
Iron
 updated question on 12 Dec 2021
1 answer
340 views
I have Blazor form that has two combo boxes.  The second combo box should be refreshed based on the value selected by user in the first combo box.
Apostolos
Telerik team
 answered on 08 Dec 2021
0 answers
131 views

Hi I have added the LoadContainer to the MainLayout. Now I can inject it like this

[CascadingParameter] protected ShowProgressIndicator Progress { get; set; }

MainLayout.razor

<TelerikRootComponent>
    <NavMenu/>
    <div class="page">
        <TelerikNotification @ref="@Notification.Instance"
                             HorizontalPosition="@NotificationHorizontalPosition.Right"
                             VerticalPosition="@NotificationVerticalPosition.Top"
                             Class="bi-notification">
        </TelerikNotification>
        <TelerikLoaderContainer Visible="@ProgressIndicator.Visible" Text="Working on it .." Size="@LoaderSize.Large"/>

        <CascadingValue IsFixed="true" Value="@Notification">
            <CascadingValue Value="@ProgressIndicator">
                @Body
            </CascadingValue>
        </CascadingValue>

    </div>
</TelerikRootComponent>

@code
{
    Notification Notification { get; } = new();
    ShowProgressIndicator ProgressIndicator { get; } = new();
}

 

What I can't get to work is setting the loading text on the LoadContainer. It's always using the default text "Loading ..."

Show/Hide works fine.

Progress.Visible = true;

public class ShowProgressIndicator
    {
        public TelerikLoaderContainer LoaderContainer { get; set; }

        public bool Visible { get; set; }
        public string Text { get; set; } = "Working on it ..";
        
        // public void Show()
        // {
        //     Text = "Working on it ..";
        //     Visible = true;
        // }
        //     
        // public void Hide()
        // {
        //     Visible = false;
        // }
    }

 

 

Martin Herløv
Top achievements
Rank 2
Bronze
Iron
Iron
 updated question on 08 Dec 2021
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?