Telerik Forums
UI for Blazor Forum
1 answer
722 views

Hi, I am trying to modify the existing code for the Hierarchical Drawer so I can have a nested nav menu in the drawer. Right now, when I add a level 2 child to a level 1 child, the level 2 child is not aligned properly; it is in line with the first original level when it should be indented. How can I fix this?

 

 


@inject IFacilityService FacilityService
@inject ILocationService LocationService


 
 <div class="custom-toolbar">
    <TelerikButton OnClick="@ToggleDrawer" Icon="menu" FillMode="@(ThemeConstants.Button.FillMode.Flat)"></TelerikButton>
    <span style="margin-left: 20px; font-weight: bold; font-size: 17px;">Wilder Fields Sensor Dashboard</span>
</div>

<TelerikDrawer @ref="@Drawer" Data="Data" MiniMode="false" Mode="@DrawerMode.Push" TItem="DrawerItem" SelectedItemChanged="@OnItemSelect" @bind-Expanded="@Expanded">
    <Template>
        <div class="k-drawer-items" role="menubar" aria-orientation="vertical">
             <LoginDisplay />
            <ul>
                @foreach (var item in context)
                {
                    var selectedClass = item == SelectedItem ? "k-state-selected" : string.Empty;
                    <li @onclick="@(() => OnItemSelect(item))" class="k-drawer-item @selectedClass">
                        <div class="k-level-@(item.Level)">
                            <TelerikIcon Icon="@item.Icon"></TelerikIcon>
                            <span class="k-item-text">@item.Text</span>
                        </div>

                        @if (item.Expanded && (item.Children?.Any() ?? false))
                        {
                            <span class="k-icon k-i-arrow-chevron-down" style="position:absolute; right:0; line-height: inherit; margin: 0 8px"></span>
                        }
                        else if (!item.Expanded && (item.Children?.Any() ?? false))
                        {
                            <span class="k-icon k-i-arrow-chevron-right" style="position:absolute; right:0; line-height: inherit; margin: 0 8px"></span>
                        }
                    </li>
                }
                
            </ul>
        </div>        
    </Template>
    <DrawerContent>
        @SelectedItem?.Description
    </DrawerContent>
</TelerikDrawer>







   

   <!--- <NotAuthorized>
        <a href="authentication/login">Log in</a>
    </NotAuthorized>-->



@code {
   
  

    

    protected override async Task OnParametersSetAsync()
    {
        await base.OnParametersSetAsync();

       
    }
    public TelerikDrawer<DrawerItem> Drawer { get; set; }
    public DrawerItem SelectedItem { get; set; }
    public bool Expanded { get; set; } = true;
    public IEnumerable<DrawerItem> Data { get; set; } =
    new List<DrawerItem>
    {
            new DrawerItem { Text = "R2D2", Icon = "question",
             Children = new List<DrawerItem>()
                {
                    new DrawerItem { Text = "Room 1", Icon = "grid", Level = 1,
                    Children = new List<DrawerItem>()
                {
                    new DrawerItem { Text = "Room 1", Icon = "grid", Level = 2 },
                    new DrawerItem { Text = "Calendar", Icon = "calendar-date", Level = 2, Description = "The Calendar component allows the user to scroll through a calendar and select one or more dates. " },
                    new DrawerItem { Text = "Menu", Icon = "menu", Level = 2, Description = "The Menu component displays data (flat or hierarchical) in a traditional menu-like structure." },
                }
                    
                    
                    
                    },
                   
                }
            
            
            
            
            
            },

            new DrawerItem {
                Text = "Components",
                Icon = "categorize",
                Description = "Blazor is still a new technology and the component suite is young. We are constantly working on adding new features and components. Tell us which components you want implemented and how you intend to use them, and Blazor, at our feedback portal.",
                Children = new List<DrawerItem>()
                {
                    new DrawerItem { Text = "Room 1", Icon = "grid", Level = 1, Description = "The Telerik Blazor Data Grid provides a comprehensive set of ready-to-use features covering everything from paging, sorting, filtering, editing, and grouping to row virtualization, optimized data reading, keyboard navigation and accessibility support." },
                    new DrawerItem { Text = "Calendar", Icon = "calendar-date", Level = 1, Description = "The Calendar component allows the user to scroll through a calendar and select one or more dates. " },
                    new DrawerItem { Text = "Menu", Icon = "menu", Level = 1, Description = "The Menu component displays data (flat or hierarchical) in a traditional menu-like structure." },
                }
            },
            new DrawerItem { Text = "Browser Support", Icon = "calendar", Description = "Browsers supported by Telerik UI for Blazor: Chrome (including Android and iOS), Edge, Firefox, Safari (including iOS)" }
        };

    public async Task ToggleDrawer() => await Drawer.ToggleAsync();

    protected override void OnInitialized()
    {
        SelectedItem = Data.First();
    }

    public void OnItemSelect(DrawerItem selectedItem)
    {
        SelectedItem = selectedItem;

        selectedItem.Expanded = !selectedItem.Expanded;
        var newData = new List<DrawerItem>();

        foreach (var item in Data.Where(x => x.Level <= selectedItem.Level))
        {
            newData.Add(item);
            if (item == selectedItem && selectedItem.Expanded && (item.Children?.Any() ?? false))
            {
                foreach (var child in item.Children)
                {
                    newData.Add(child);
                }
            }

            if (item != selectedItem && !(item.Children?.Contains(selectedItem) ?? false))
            {
                item.Expanded = false;
            }
        }

        Data = newData;
    }

    public class DrawerItem
    {
        public string Text { get; set; }

        public string Icon { get; set; }

        public bool Expanded { get; set; }

        public int Level { get; set; }

        public string Description { get; set; }

        public IEnumerable<DrawerItem> Children { get; set; }
    }


     


   
}


<style>
    #demo-runner {
        height: 600px;
    }

    .k-drawer-content {
        padding: 25px;
        font-size: 18px;
    }

    .k-drawer-container {
        position: relative;
        width: 100%;
        height: 95%;
    }

    .k-drawer .k-drawer-item {
        white-space: nowrap;
        overflow: hidden;
    }

    .k-level-1 {
        padding-left: 20px;
    }

    .custom-toolbar {
        width: 100%;
        background-color: #f6f6f6;
        line-height: 10px;
        border-bottom: inset;
        border-bottom-width: 1px;
        padding: 3px 8px;
        color: #656565;
    }
</style>

Svetoslav Dimitrov
Telerik team
 answered on 23 Mar 2022
0 answers
162 views

Hello everyone,

Is there an event that is fired when the column changes it's position by reordering it?

Thank you,
Cipri

Ciprian Daniel
Top achievements
Rank 1
Iron
Iron
Iron
 asked on 23 Mar 2022
0 answers
354 views

I use blazor chart component and it works quite fine. The problem starts when printing the current html page (CTRL+P) then the chart gets cut off on the right side and does not scale correctly. As you can see in my screenshot the table above the chart is scaled ok but the chart is cut off.

What can I do to print the chart in a correct way?

Regards
Heiko

Heiko
Top achievements
Rank 1
Iron
Veteran
 asked on 22 Mar 2022
0 answers
842 views

I have experience with Linq Expressions and like to implement my own. 

The gridState.FilterDescriptors.Add method accepts anything of interface IFilterDescriptor.

However, when I give it my own implementation of IFilterDescriptor, it compiles fine but then throws an error during runtime:

System.InvalidCastException: 'Unable to cast object of type 'MyFilterDescriptor' to type 'Telerik.DataSource.FilterDescriptor'.'

I thought to inherit Telerik.DataSource.FilterDescriptor and Telerik.DataSource.CompositeFilterDescriptor and override the CreateFilterExpression method, but that didn't work either, as it always ends up calling the method in the base FilterDescriptor.

Is this by design, or is there a way now or in the future to implement my own IFilterDescriptor?

Thanks.

Alex
Top achievements
Rank 1
Iron
Iron
 updated question on 22 Mar 2022
0 answers
96 views

Hello everyone,

Is there a possibility to set some properties regarding the design of the grid for example:
- header background color
- rounded corners
- interlaced, flat design for the rows, now it's interlaced by default, I mean, a row white, a row grey, by flat I mean all rows in the same color, white for example

I know that this changes can be done from CSS but if I do them I don't want to influence the design for the active row for example, so I'm interested if there can be a much nicer solution.

Thank you,
Cipri

Ciprian Daniel
Top achievements
Rank 1
Iron
Iron
Iron
 updated question on 21 Mar 2022
1 answer
129 views

I am using TreeList and a custom template on a column to display user avatar. I also need to sort and filter on this column. However when combine all of these features (sort and filter) on a template column, it doesn't work. There are 2 scenarios:

- When enable sort, the filtering works

- When disable sort, the filtering doesnt work

Is there any work around solution for this? I am using UI for Blazor 3.0.1

 

My snippet

https://blazorrepl.telerik.com/mQuxlWkD32B5eGay33

Radko
Telerik team
 updated answer on 21 Mar 2022
0 answers
114 views

Hi,

We're new to Teleric UI control and we plan to build a one page on Blazer client and use Blazor server in the Server side. 

The server contains business logic to connect to a Azure DB.  On client side, we provide a simple textbox to input search parameter and trigger a DB search. The result will be returned by several stored procedure kind of functions. 

On the client side, we hope to display a tree.  When user click the root node, it'll expand with 3 child nodes. We hope to do data binding to a data table in the node. 

Does TreeList  or TreeView control support that functionality?

Thanks,

Ellen

Ellen
Top achievements
Rank 1
 asked on 21 Mar 2022
1 answer
480 views

Hello,

is there a way to avoid collapsing and/or expanding tree items depending on the value of a property from the data model ?

 

Additionally a feature request would be helpful: E.g.

Model:

class Node {
  public int Id {get;set;}
  public int ParentId {get;set;}
  public string Name {get;set;}
  public bool IsExpanded {get;set;}
  public bool IsCollapsed {get;set;}
  public bool CanExpanded {get;set;}
  public bool CanCollapsed {get;set;}
}

Bind properties IsExpanded/IsCollapsed to the tree => OnInitial render the node is expanded/collapsed

Bind properites CanExpanded/CanCollapsed to the tree => able to expand/collapse a tree node (and render the indicator differently)

 

Marin Bratanov
Telerik team
 answered on 19 Mar 2022
1 answer
1.1K+ views
I want to provide a dropdownlist with some known values.  There is a chance that the user will want to input another value other than in the dropdown.  Is there an example of having a dropdown list with either a optional value that can be specified in a textbox or such?
Marin Bratanov
Telerik team
 answered on 19 Mar 2022
1 answer
115 views

Hello, 

Any way possible that a custom method can be fired using the selected items from multiselect. There is absolutely no where in the documentation to specify this. It is only provided SelectedItemsChanged that takes lambda. When trying to fire a custom method on selected items when the user clicks a button, the follwing   error is thrown: 

Argument 2: cannot convert from 'method group' to 'EventCallback' .

 

It is provided a link below : The lambda expression in the handler is required by the framework: https://github.com/aspnet/AspNetCore/issues/12226

It doesn't really make sense why this link has been provided as it takes you to a blog page and absolutely no solution is provided.


So may I ask, how do you fire a custom method only on the selected items?

Thank you.

7

Kind regards

 

Marin Bratanov
Telerik team
 answered on 18 Mar 2022
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?