Telerik Forums
UI for Blazor Forum
0 answers
98 views
i have one button when i click that button it will excecute storedprocedure and generate excel file in Asp.net core Blazor Application
Pranay
Top achievements
Rank 1
 asked on 17 May 2022
1 answer
332 views

I am using a TreeView control that displays checkboxes for each node and the checked state of each node seems to get lost when the parent node is collapsed and expanded again.  However, this only seems to happen when the OnExpand event is handled. Remove the OnExpand event handler and everything works as expected. It doesn't seem to make a difference if the event args property ShouldRender is set to true. Happens for both flat and hierarchical data.

Can't imagine that this is the desired behaviour. If it is then is there any way around it as I do need to handle the OnExpand event in my code behind.

The following is test page the displays this problem...

@page "/treeview"
@using System.Linq

<TelerikTreeView Data="@Data" CheckBoxMode="@TreeViewCheckBoxMode.Multiple" CheckChildren="true" CheckParents="true"
                 @bind-CheckedItems="@CheckedItems" OnExpand="@OnExpandHandler">
                 @*@bind-ExpandedItems="@ExpandedItems"*@
    <TreeViewBindings>
        <TreeViewBinding IdField="Id" TextField="Text" HasChildrenField="HasChildren" ItemsField="Children">
            <ItemTemplate>
                @{ 
                    var item = context as MyTreeItem;
                    <div>@item.Id.ToString() : @item.Text</div>
                }
            </ItemTemplate>
        </TreeViewBinding>
    </TreeViewBindings>
</TelerikTreeView>

@code {
    private IEnumerable<MyTreeItem> Data { get; set; }
    private IEnumerable<object> CheckedItems { get; set; } = Enumerable.Empty<object>();
    private IEnumerable<object> ExpandedItems { get; set; } = Enumerable.Empty<object>();
    private int LastID = 0;

    protected override void OnInitialized()
    {
        Data = CreateNodeList("one", "two", "three", 3);
    }

    private List<MyTreeItem> CreateNodeList(string name1, string name2, string name3, int levels = 0)
    {
        var list = new List<MyTreeItem>();
        list.Add(CreateNode(name1, levels));
        list.Add(CreateNode(name2, levels));
        list.Add(CreateNode(name3, levels));
        return list;
    }

    private MyTreeItem CreateNode(string name, int levels)
    {
        LastID++;
        var node = new MyTreeItem { Id = LastID, Text = name };
        if (levels > 0)
        {
            node.Children = CreateNodeList($"{name} - one", $"{name} - two", $"{name} - three", levels - 1);
        }
        return node;
    }

    private async Task OnExpandHandler(TreeViewExpandEventArgs args)
    {
        //await InvokeAsync(StateHasChanged);
        //args.ShouldRender = true;
    }

    private class MyTreeItem 
    {
        public int Id { get; set; } = 0;
        public string Text { get; set; } = "";
        public IList<MyTreeItem> Children { get; set; } = null;
        public bool HasChildren => Children is not null && Children.Count > 0;
    }
}

Tsvetomir
Telerik team
 answered on 17 May 2022
1 answer
265 views

Hi,

Is there a way to change the position of the small Arrow of the tooltip through css ?

 

thx!

Robert
Top achievements
Rank 1
Iron
Iron
 updated answer on 17 May 2022
1 answer
136 views

Hello,

I'm still trying to produce a reproducible scenario in Repl to share, but upgrading to 3.3.0 broke our treeview drop code. If I revert back to 3.2.0 it begins to work properly again.  I have a typical tree with several "folders" & "files" which I can drag and drop to re-organize. The only time telerik shows the circle with a slash drag hint is when you drag the source node over top itself. In 3.3.0 it seems that the circle with the slash is showing up over most but not all of the nodes in the tree. I can't explain why it thinks some areas are valid drop targets and others are not. One node is fine to drop on and the next and previous ones show the No Drop icon. 

I'll continue to try and make a Repl example but wanted to raise awareness of this sooner than later.

Thanks,

-Andy 

Andrew
Top achievements
Rank 1
Iron
Iron
 answered on 16 May 2022
1 answer
395 views

Hello

We have added validation to the Grid using Fluent Validation and this works perfectly. However in the validation we have to go to a back-end API to check if the value is not a duplicate.

The current behavior is that the Fluent Validation goes off whenever you type, this causes a lot of load on the API. Is there a way to change this? Maybe so it only occurs when you press the Save button, or when you leave the input field, or after x seconds of no typing...

Another valid option would be to do the check in the Update or Create Handler, but how do we display a nice error message that way to the user?

Thank you in advance

Thomas

 

Tsvetomir
Telerik team
 answered on 16 May 2022
1 answer
143 views

Opening the page it return this error on chrome console:

 

System.AggregateException: One or more errors occurred. (Could not load list of method overrides due to Method not found: System.Collections.Generic.IList`1<Microsoft.Extensions.Configuration.IConfigurationSource> Microsoft.Extensions.Configuration.IConfigurationBuilder.get_Sources())
 ---> System.TypeLoadException: Could not load list of method overrides due to Method not found: System.Collections.Generic.IList`1<Microsoft.Extensions.Configuration.IConfigurationSource> Microsoft.Extensions.Configuration.IConfigurationBuilder.get_Sources()
   at Microsoft.AspNetCore.Components.WebAssembly.Hosting.WebAssemblyHostBuilder.CreateDefault(String[] args)
   at BlazorRepl.Client.Program.Main(String[] args)
   --- End of inner exception stack trace ---
callEntryPoint @ blazor.webassembly.js:1
VM262:1 Uncaught ReferenceError: webVitals is not defined
    at <anonymous>:1:313
    at gtm.js?id=GTM-6X92:502:414
    at HTMLScriptElement.<anonymous> (gtm.js?id=GTM-6X92:503:118)

Dimo
Telerik team
 answered on 16 May 2022
1 answer
210 views

I have a grid defined with SelectionMode="GridSelectionMode.Single".  I'm handling the SelectedItemsChanged event and when returning the previously selected row is selected with the newly selected row.  This appears to be happening when an async call to a web api using http client is made.  If I comment out the http call the selection works as expected.

Can someone explain why the http client call could be impacting the selection functionality or how I may go about debugging this?


	

<div ><div ><label for="label">Labels</label><div ><TelerikGrid Data="@Labels" FilterMode="@GridFilterMode.FilterRow" ScrollMode="GridScrollMode.Scrollable" SelectionMode="GridSelectionMode.Single" SelectedItems="@SelectedLabels" SelectedItemsChanged="@((IEnumerable<LabelDto> labelList) => OnSelectAsync(labelList))" Height="200px"><GridColumns><GridColumn Field="@(nameof(LabelDto.Name))"></GridColumn></GridColumns></TelerikGrid></div></div></div> public partial class LabelSelection { private ObservableCollection<LabelDto>? _labels; private int? _selectedValue; public IEnumerable<LabelDto> SelectedLabels { get; set; } = Enumerable.Empty<LabelDto>(); protected async Task OnSelectAsync(IEnumerable<LabelDto> labels) { var l = labels.ToList(); SelectedLabels = l; if (l.Any()) await LabelChangedAsync(l[0]); StateHasChanged(); } ... } public async Task LabelChangeHandlerAsync(LabelDto label) { _currentLabel = label; var labelWithAttributes = await LabelRepo.GetLabelAsync((int)label.Id); //LabelAttributeList.Clear(); //if (labelWithAttributes.Attributes.Any()) //{ // LabelAttributeList.AddRange(labelWithAttributes.Attributes); //} }

 

        public async Task<LabelWithAttributesDto> GetLabelAsync(int id)
        {
            var req = $"labels/{id}?includeAttributes=true";

            _logger.Log(LogLevel.Warning, $"GetLabelsAsync({_client.BaseAddress}{req})...");

// The next call will cause multiple rows to be selected. Commenting this out will make the selections work.
           var apiResponse = await _client.GetStreamAsync(req);
//_logger.Log(LogLevel.Warning, $"...back from GetLabelsAsync({_client.BaseAddress}{req})");

//var label = await JsonSerializer.DeserializeAsync<LabelWithAttributesDto>
//    (apiResponse, new JsonSerializerOptions() { PropertyNameCaseInsensitive = true });

//return label;
return new LabelWithAttributesDto(1, "new", "filename", "100", new List<LabelAttributeDto>());
        }


Marin Bratanov
Telerik team
 answered on 15 May 2022
2 answers
2.3K+ views

I want to make a Custom GridCommandbutton Visible based on a value in the row.

For example, if the Status column of a row is 2, I want the command button to be visible, otherwise I want it hidde.

Is this possible?

 

Jay
Top achievements
Rank 1
Iron
 updated answer on 12 May 2022
0 answers
359 views

Started seeing errors after updated V.S.   Pages that uses TelerikGrid has these 2 errors.  It compiles fine and run fine, so i'm not sure how to fix.

Error (active) CS1503 Argument 2: cannot convert from 'Microsoft.AspNetCore.Components.EventCallback<System.Collections.Generic.IEnumerable<mymodel>>' to Microsoft.AspNetCore.Components.EventCallback'

Error (active) CS0246 The type or namespace name 'TItem' could not be found (are you missing a using directive or an assembly reference?)

 

Please advise
Thanks, ZB

Zack
Top achievements
Rank 1
 asked on 12 May 2022
1 answer
139 views

Hi all,

I'm having a hard time implementing a DateTime picker in a Grid. I'd like to set up the grid using the hierarchy feature and implement InCell editing. I created a version of my problem in the Telerik REPL and have observed the same issue in my current code.

 

https://blazorrepl.telerik.com/wmEfuDcn54Cv6ZNO07

 

As you can see, the DateTime picker works fine in the parent table. But when it is implemented in the child table, it seems that clicking on the DateTime picker actually takes the cell out of focus.

Does anyone know if there is a workaround or if this is a bug?

Thanks

 

Edit: I added the screenshots when I noticed that the REPL link wasn't loading correctly on my Chrome or Edge browser

Nadezhda Tacheva
Telerik team
 answered on 12 May 2022
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
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?