Telerik Forums
UI for Blazor Forum
0 answers
223 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
410 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
186 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
0 answers
285 views

I feel a bit silly not being able to find the "right" solution to this, but here it goes...

I see the Blazor Card demos has an Expandable demo. I want to do something a lot like this but I will have many cards, each one of them should be able to expand it's own "sub-content" at will. The demo shows a single button tied to a single TelerikAnimationContainer. What is the best solution to have 1-n cards, each with their own expandable content that slides out? (mine will slide out to the right, but I don't know that that matters).

 

Thanks,

Justin

Telerik UI for Blazor 2.29.0

Justin
Top achievements
Rank 1
 asked on 08 Dec 2021
1 answer
942 views

<TelerikButton>Hello</TelerikButton>

generates a button with "HELLO" as the text...all uppercase. Looks like the .k-button css class has "text-transform: uppercase" on it. Is this due to the Material theme? I am using Telerik.UI.for.Blazor.2.29.0, which is the latest as of this writing.

I would like the casing of the text to be how I decide.

Thanks,

Justin

Matthias
Top achievements
Rank 5
Bronze
Bronze
Iron
 answered on 08 Dec 2021
1 answer
1.4K+ views

I want to ask if there are classes for adding hover and selected styles for the Card?

Would also like the card to act as one big button.

Dimo
Telerik team
 answered on 07 Dec 2021
1 answer
243 views

Hello,

I have a telerik menu, with a submenu in it. How do I stop the primary menu from closing, when dragging the mouse out of the submenu in the "wrong" position? Or is it possible to align the submenu to the left of the primary menu?

Its a bit hard some times to reach all menu items below the submenu trigger, when the primary menu keeps closing.

Video:
https://youtu.be/oFT09e17gyk

Thanks
Regards,
Nikolas

Apostolos
Telerik team
 answered on 07 Dec 2021
1 answer
1.4K+ views

Hi,

how can I cancel the edit mode programmatically in Inline edit mode?

Apostolos
Telerik team
 answered on 07 Dec 2021
2 answers
126 views

Hi I would like something similar to the search in bootstrap doc where you can type CTRL+/ to set focus in the search field.

Are there any components/utils I can use in the Telerik Blazor lib?

 

Found this jsakamoto/Toolbelt.Blazor.HotKeys: This is a class library that provides configuration-centric keyboard shortcuts for your Blazor WebAssembly (client-side) apps. (github.com)

Martin Herløv
Top achievements
Rank 2
Bronze
Iron
Iron
 answered on 07 Dec 2021
2 answers
1.0K+ views

Is there a way to force tabs to wrap when there are more tabs than there is space in a horizontal viewport?  I am running into an issue where too many tabs get generated and they end up rendering outside the viewport causing the user to have to scroll.  

The idea is to render something like this.

[Tab 1] [Tab 2] [Tab 3] [Tab 4] [Tab 5] [Tab 6] [Tab 7] [Tab 8]
[Tab 9] [Tab 10]

Dimo
Telerik team
 answered on 06 Dec 2021
Narrow your results
Selected tags
Tags
+? more
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?