Telerik Forums
UI for Blazor Forum
1 answer
190 views

Hi,

I'm trying to understand if there is any difference between using TreeList.GetState() and TreeList.State? I want to examine the state of the tree list in the most efficient manner possible, and TreeList.State seems like the obvious choice, but the docs all use the GetState() method.

Thanks.

Dimo
Telerik team
 answered on 15 Jun 2022
1 answer
693 views

Hi,

I've bound a TreeList to flat data. How can I determine if the TreeList has determined that a given row can be expanded/collapsed based upon the flat data, (i.e., how can I determine whether or not an expend/collapse arrow has been placed on the row)? This has an additional complexity in that the list cannot expand/collapse a row if it does not have children.

A use case for this would be to react to a double-click in a row and expand or collapse the row if the row is allowed to do that.

Dimo
Telerik team
 answered on 15 Jun 2022
2 answers
1.5K+ views

I am trying to use the File Select component in a Blazor WASM app to upload a file. However, when I try to read the stream in the FileSelectEventArgs object, it's coming out empty. I do get a value for the stream length but reading it into a byte array is producing an array of 0's. Here's my code:

@code {
    List<string> CpmAllowedExtensions { get; set; } = new List<string> { ".pdf" };

    async Task HandleFiles(FileSelectEventArgs args)
    {
        foreach (var file in args.Files)
        {
            if (!file.InvalidExtension)
            {
                var b = new byte[file.Stream.Length];
                await file.Stream.ReadAsync(b, 0, b.Length);
                //b is blank here
            }
        }
    }
}

<TelerikFileSelect OnSelect=@HandleFiles AllowedExtensions="@CpmAllowedExtensions"></TelerikFileSelect>

How do I get to the byte array in the file so that I can upload it? The example I see in the Docs doesn't seem to be for uploading a file and trying to use a filestream as it does is producing the same result as my code above.

Also, I tried uploading the file.Stream using a SteamContent object but nothing is getting sent in the request payload.

Nadezhda Tacheva
Telerik team
 answered on 14 Jun 2022
0 answers
180 views
I have a grid with a hierarchy grid inside it. I can expand each row in the master grid but when I edit one row (I use popup mode to edit) after closing the popup all rows collapse. 
I try to save the grid state and then set the state in the OnStateChangeHandler event but its not working correctly it seems that the grid state has been set after closing popup by an unknown event.
mahdi
Top achievements
Rank 1
 asked on 13 Jun 2022
1 answer
364 views

Hi,

I am following below demo for adding custom filter menu with checboxes.

https://demos.telerik.com/blazor-ui/grid/custom-filter-menu

But it doesn't come with SelectAll checkbox option, please let me know how can add that option.

 

regards,

nitesh

Timothy J
Top achievements
Rank 2
Bronze
Iron
Iron
 answered on 10 Jun 2022
2 answers
678 views

The DialogFactory.Dialogs methods are really convenient but the prompt is missing some functionality:

- how can u distinguish pressing Cancel from pressing Ok without entering a value (both return null)

- there should be a way to make it mandatory (solves the above)

- what about setting a default value?

 

or am I missing something?

Timothy J
Top achievements
Rank 2
Bronze
Iron
Iron
 updated answer on 10 Jun 2022
0 answers
413 views

Hello,

I think I'm missing something in the (sparse) documentation of the Upload part of the Filemanager component, specifically this page:

https://docs.telerik.com/blazor-ui/components/filemanager/upload

The sample provided on this page places uploaded files in the FlatFileEntry list before clicking on the button OK or Cancel on the Upload dialog. I don't want that, I want to update the FlatFileEntry list after clicking OK or doing nothing (or discarding the uploaded file still at its temporary location where the api did put it) after clicking Cancel. 

Which events are fired after clicking on these buttons? Does anyone have some sample code that is a bit more verbose than the almost identical sample that is pasted on every documentation page?

Kind regards,
Kees Alderliesten

Kees
Top achievements
Rank 2
Iron
Iron
 asked on 09 Jun 2022
1 answer
381 views

Hi,

I'm trying to bind the tree list to a list of Dictionary<string. object> objects, where the TreeListColumn.Field equals the key in the Dictionary for that row. This works fine for displaying the data in the tree. However, when I try to set the sorting state by specifying a column name to sort by, I get the following error inside Telerik:

Error: System.ArgumentException: Invalid property or field - 'Name' for type: DynamicEntityBase
   at Telerik.DataSource.Expressions.MemberAccessTokenExtensions.CreateMemberAccessExpression(IMemberAccessToken token, Expression instance)
   at Telerik.DataSource.Expressions.ExpressionFactory.MakeMemberAccess(Expression instance, String memberName)
   at Telerik.DataSource.Expressions.ExpressionFactory.MakeMemberAccess(Expression instance, String memberName, Boolean liftMemberAccessToNull)
   at Telerik.DataSource.Expressions.PropertyAccessExpressionBuilder.CreateMemberAccessExpression()
   at Telerik.DataSource.Expressions.MemberAccessExpressionBuilderBase.CreateLambdaExpression()
   at Telerik.DataSource.SortDescriptorCollectionExpressionBuilder.Sort()
   at Telerik.DataSource.Extensions.QueryableExtensions.Sort(IQueryable source, IEnumerable`1 sortDescriptors)
   at Telerik.Blazor.Data.TelerikTreeListDataSource`1.SortItems(IEnumerable`1 tree)
   at Telerik.Blazor.Data.TelerikTreeListDataSource`1.SortItems(IEnumerable`1 tree)
   at Telerik.Blazor.Data.TelerikTreeListDataSource`1.SortItems(IEnumerable`1 tree)
   at Telerik.Blazor.Data.TelerikTreeListDataSource`1.SortItems(IEnumerable`1 tree)
   at Telerik.Blazor.Data.TelerikTreeListDataSource`1.SortTree()
   at Telerik.Blazor.Data.TelerikTreeListDataSource`1.InitData(IEnumerable`1 sourceData)
   at Telerik.Blazor.Data.TelerikTreeListDataSource`1.ProcessData(IEnumerable data)
   at Telerik.Blazor.Components.Common.DataBoundComponent`1.ProcessDataInternal()
   at Telerik.Blazor.Components.Common.DataBoundComponent`1.OnParametersSetAsync()
   at Telerik.Blazor.Components.TelerikTreeList`1.OnParametersSetAsync()
   at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)

 

Is there a work around for this, or can sorting by done by some other method? We want to use a Dictionary since we are dynamically creating the data to bind to instead of hard-coding a specific POCO for each page.

Dimo
Telerik team
 answered on 09 Jun 2022
5 answers
2.0K+ views

Hello,

I want to remove white space in drop down values in blazor. Please see the image below.

Could please suggest on this

 

 

 

Nadezhda Tacheva
Telerik team
 answered on 09 Jun 2022
1 answer
1.2K+ views

Blazor DEEP LINKING Support:  -  seeking suggestions or interest.

I have discovered that Blazor "Deep Linking" is something with not much .NET API support and community code blogs.

ShortComing: 
This solution does not use the LocationChanged Event. Blazors NavigationManager LocationChanged Event is not friendly enough to support deep linking URL's that are not managed under a Blazor "Circuit".  eg an initial request by clicking a browser history/favorite link. 
KeyNote: 
So far, the findings indicate that the LocationChanged Event will not fire for this type of initial web request with subsequent requests managed in a Blazor "Circuit". It's too late because the first request was not caught by the LocationChanged  Event. 


Obtained GOAL:

Supports detailed "deep linking" to Restore Navigation UI Components and also restore workflow state for a page defined in the URL route. 

This is a Blazor Server implementation to support Blazor "Deep Linking". 
The code base has been refined, good comments and well ordered.; looking production ready. 
Blazor Server was chosen to reduce the security attack surface. The application using this type solution is not ultra high bandwidth so adding a few extra micro-seconds (or even a milli-second) of code runtime is not an issue. 

>>> Before scaling out adding application page-specific content, now seeking alternatives, insight and suggestions (yeah, should have asked sooner) 
               >>> Ideally, I should have created a few block diagrams and code fragments to help visualize. (perhaps support files can be added if further interest.)


Primary Application Components: 
The MainLayout Component supports four primary Blazor Components:
 1) "Module List":    in the upper title area, a TelerikBreadcrumb Component showing a list of "Module Items" to click on.
 2) "Module Item":   a TelerikTreeView Component containing a navigational hierarchical list of TreeItems located along the left side of the page. Each TreeItem contains url route segments to a Blazor Page Component. Each item contains properties for customization.
 3) "NavBreadcrumb":   a TelerikBreadcrumb Component showing the clicked selectedTreeView item, and its parent items.  Located just above the Module Item on the left side MainLayout Component. 
 4) "Page": the Page Component in the selected TreeItem from the selected ModuleItem.   KeyNote: in this solution, a page may be under multiple module list and module items.  Thus the format of the URL route as defined below. 

URL Route Schema: 
The following is the overall Route Template scheme for the website solution: 
     / ModuleListName / ModuleItemName / PageName / optionalRouteParam1 / optionalRouteParam2 ? value1=xxx & value2=yyy

In each Page Component, the @Page Directive Is Not used. Instead, @attribute [Route("route template")] is used in all page type components. This allows the use of string constants.  @Page only allows string literals.

Here are two example route templates in one of the Page Components:   (each page may contain multiple routes)
   @attribute [Route($"/{ModuleListName.Tenant}/{ModuleItemName.ClientAdmin}/{PageItem.UserGrid}/{PageAction.Manage}")]
   @attribute [Route($"/{ModuleListName.Tenant}/{ModuleItemName.UserAdmin}/{PageItem.UserGrid}/{PageAction.Search}")]

Naming Constants and Dictionary:
In the above example, four static classes with multiple static string constants are used to define all navigation type lists and items, and the routing/query string values:
  The four static classes are: 
    ModuleList    -   A list of possible Module lists to display in the MainLayout Title Area. (each contains a list of "ModuleItems")
    ModuleItem   -  An item in each of the above Module Lists
    PageItem       -  The actual Page Component Name  (pageitems use "nameof(pagecomponent)" to assign a page item value.
    PageAction   -  Optional route fragments

Key Point: using string constants in a centrally located file subdirectory allows global renaming. And, allows using friendlier names in the source code while using more-so cryptic names in the built public url routes. 
* it does come with a bit of overhead managing names and assigned values but IMO worth the organizational effort; especially after the solution grows with many pages and complex list/item navigation. Maintaining this type information can be handled by even non-coders with app/solution familiarity.

 

App Specific Component Base Class:
A base class that inherits "ComponentBase" is used by all page components instead of ComponentBase. This is where incoming URL requests are handled. This class contains a number of methods and state management that are in common to all pages. 

Route Manager Class:  

There are "ModuleList" and ModuleItem" definition files that are essentially dictionary's to look up a name to .NET Type then activate the type to an instance. 
The "RouteManager" class contains URL Encoding and URL Decoding methods.

Route Manager - URL Encoding:
When a user clicks on a ModuleItem TreeItem selection, the tree item information is passed to a URL Encoding method to build a "deep link". Also, application specific query string parameters are appended. 

Route Manager - URL Decoding:
The incoming request route segments are parsed and mapped to the above blazor components:  ModuleList, ModuleItem, PageItem.
If a route change is detected, then events are fired to notify the MainLayout Component to update the affected component contents.

SessionStateManger Service Class:
Implemented is a comprehensive more-so generic type session manager class. It handles app-specific requirements. 
Retaining login and navigation to all "module's". ie the feature set and supporting pages. 
The solution also contains other supporting code.

>>> Overall, there is a lot going on to manage everything thus creating a working API for all page component content developers to code around as an de-facto standard. 


DEEP LINKING:

Using the above, the blazor solution supports detailed deep linking to fully restore state; restoring the four primary components listed above. Plus, optional route fragments and query string values to further define state for a given page component. 


*** I hope I have described the architecture clearly enough to grasp and visualize the implementation.***

I'd appreciate relevant input to affect the outcome of the implementation. 

Daniel
Top achievements
Rank 1
Iron
 answered on 06 Jun 2022
Narrow your results
Selected tags
Tags
+? more
Top users last month
Tien
Top achievements
Rank 1
Iron
Krasimir
Top achievements
Rank 3
Bronze
Iron
Iron
Cedar
Top achievements
Rank 1
Iron
Emil
Top achievements
Rank 1
Iron
Kyle Watson
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Tien
Top achievements
Rank 1
Iron
Krasimir
Top achievements
Rank 3
Bronze
Iron
Iron
Cedar
Top achievements
Rank 1
Iron
Emil
Top achievements
Rank 1
Iron
Kyle Watson
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?