Telerik Forums
UI for Blazor Forum
1 answer
613 views

Hello,

I tried to implement a TelerikRadioGroup bound to an enum by following Marin's example code posted here, but I'm doing something wrong.  I have attached my Razor component as a TXT file. 

The result when I run the code is this:

Thanks again for your support.

Francis

 

Marin Bratanov
Telerik team
 answered on 29 Jul 2021
0 answers
1.5K+ views

I've just started to look into building custom filter templates and using the example here to help me.

I've noticed that when I click the 'Clear' button, it will clear the checkbox items but if I select a new item, on hitting 'Filter' it will re-add previous selections to the filter and they will show on the checkbox menu again.

Can someone show me how I'd modify the example to rectify this please, and get it to filter correctly after clearing the intial selection?

This is the code from the example I've used, unmodified:

@using Telerik.DataSource

This custom filter menu lets you choose more than one option to match against the data source

<TelerikGrid Data=@GridData FilterMode="@GridFilterMode.FilterMenu"
             Height="400px" Width="600px" Pageable="true">
    <GridColumns>
        <GridColumn Field="Id" Filterable="false" Width="80px" />

        <GridColumn Field="Size">
            <FilterMenuTemplate>
                @{
                    // we store a reference to the filter context to use in the business logic to show we can
                    // we could, alternatively pass it as an argument to the event handler in the lambda expression
                    // which can be useful if you want to use the same filter for several columns
                    // you could then pass more arguments to the business logic such as field name and so on
                    theFilterContext = context;
                }

                @foreach (var size in Sizes)
                {
                    <div>
                        <TelerikCheckBox Value="@(IsCheckboxInCurrentFilter(context.FilterDescriptor, size))"
                                         TValue="bool"
                                         ValueChanged="@((value) => UpdateCheckedSizes(value, size))"
                                         Id="@($"size_{size}")">
                        </TelerikCheckBox>
                        <label for="@($"size_{size}")">
                            @if (size == null) // part of handling nulls - show meaningful text for the end user
                            {
                                <text>Empty</text>
                            }
                            else 
                            {
                                @size
                            }
                        </label>
                    </div>
                }
            </FilterMenuTemplate>
        </GridColumn>

        <GridColumn Field="ProductName" Title="Product" Filterable="false" />
    </GridColumns>
</TelerikGrid>

@code {
    FilterMenuTemplateContext theFilterContext { get; set; }
    public List<string> CheckedSizes { get; set; } = new List<string>();

    public bool IsCheckboxInCurrentFilter(CompositeFilterDescriptor filterDescriptor, string size)
    {
        // get all current filter descriptors and evaluate whether to select the current checkbox
        // the default value for string filter descriptors is null so it would select the null checkbox always
        // so we will add a check to ensure it matches the desired operator - IsNull (see the UpdateCheckedSizes method below)
        if (size == null)
        {
            foreach (FilterDescriptor item in filterDescriptor.FilterDescriptors)
            {
                if(item.Operator == FilterOperator.IsNull)
                {
                    return true;
                }
            }
            return false;
        }
        return filterDescriptor.FilterDescriptors.Select(f => (f as FilterDescriptor).Value?.ToString()).ToList().Contains(size);
    }

    public void UpdateCheckedSizes(bool value, string itemValue)
    {
        // update the list of items we want to filter by
        var isSizeChecked = CheckedSizes.Contains(itemValue);
        if (value && !isSizeChecked)
        {
            CheckedSizes.Add(itemValue);
        }

        if (!value && isSizeChecked)
        {
            CheckedSizes.Remove(itemValue);
        }

        // prepare filter descriptor
        var filterDescriptor = theFilterContext.FilterDescriptor;

        filterDescriptor.FilterDescriptors.Clear();
        // use the OR logical operator so we include all possible values
        filterDescriptor.LogicalOperator = FilterCompositionLogicalOperator.Or;
        CheckedSizes.ForEach(s => {
            // instantiate a filter descriptor for the desired field, and with the desired operator and value
            FilterDescriptor fd = new FilterDescriptor("Size", FilterOperator.IsEqualTo, s);
            // set its type to the field type you filter (the Size field in this example)
            fd.MemberType = typeof(string);
            // handle null values - use a specific filter operator that the user cannot select on their own
            // in this custom filter template (the grid has it in a dropdown by default)
            if(s == null)
            {
                fd.Operator = FilterOperator.IsNull;
            }

            filterDescriptor.FilterDescriptors.Add(fd);
        });

        //ensure there is at least one blank filter to avoid null reference exceptions
        if (!filterDescriptor.FilterDescriptors.Any())
        {
            filterDescriptor.FilterDescriptors.Add(new FilterDescriptor());
        }
    }

    // sample grid data

    public List<SampleData> GridData { get; set; }

    protected override void OnInitialized()
    {
        GridData = Enumerable.Range(1, 70).Select(x => new SampleData
        {
            Id = x,
            Size = Sizes[x % Sizes.Length],
            ProductName = $"Product {x}"
        }).ToList();
        base.OnInitialized();
    }

    public class SampleData
    {
        public int Id { get; set; }
        public string Size { get; set; }
        public string ProductName { get; set; }
    }

    public string[] Sizes = new string[] { "XS", "S", "M", "L", "XL", null };
}

 

 

 

Jenna
Top achievements
Rank 1
 asked on 29 Jul 2021
1 answer
626 views

Hello.

When using the editor at the present time, the problem arises in that you cannot insert a picture from a local computer, but you need to download it somewhere, and then insert the url's image.
Will the system be improved to upload pictures from the local computer or use drag and drop?

(copy/paste no work perfectly u can't upload image with big size)

-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/

При использовании редактора в настоящее время, возникает проблема в том что нельзя вставить картинку с локального компьютера, а необходимо загрузить куда то, а потом вставить урл. 
Будет ли доработана система, что  можно будет загружать картинки с локального компьютера и использовать драг/дроп? 

 

Marin Bratanov
Telerik team
 answered on 28 Jul 2021
0 answers
221 views

Hello.
I wanted to know how I can modify the WizardStepper template? Basically I want to customize the WizardStepper in a similar way to when it is customized in the Stepper component (https://docs.telerik.com/blazor-ui/components/stepper/step-template).

Since the WizardStepper is actually a Stepper, I suppose this is possible. The point is that I have not managed to do it. I'd tried WizardStepperSettings but only two properties can be configured from here (StepType and Linear).  

Thanks.

Blazorist
Top achievements
Rank 2
Bronze
Iron
Iron
 asked on 27 Jul 2021
1 answer
368 views

Hello,

I was wondering if/when you will offer a larger selection of themes for your Blazor components?

Other vendors, e.g. DevExpress, have large theme selections, as seen here https://demos.devexpress.com/blazor/GridColumnTypes

Right now, you only have three, which are very similar to one another. Users commonly want to have a dark theme, for example, and you don't offer any.

Please advise.

Thank you.
Matthias
Top achievements
Rank 5
Bronze
Bronze
Iron
 updated answer on 27 Jul 2021
2 answers
237 views

I have a wizard where I have defined OnChange events for the steps and I am also creating my own custom buttons.

the event fires when a step is clicked on in the progress bar, but they do not fire when clicking on the buttons in the WizardButtons.

I have created my next and previous button just like in your example for custom buttons.


if (index > 0)
{
   <TelerikButton ButtonType="ButtonType.Button" OnClick="@(() => step -= 1)">Previous</TelerikButton>
}
if (index < lastStep)
{
   <TelerikButton ButtonType="ButtonType.Button" OnClick="@(() => step += 1)" Primary="true">Next</TelerikButton>
}
How do I make the button clicks fire the OnChange event for the step?
Nadezhda Tacheva
Telerik team
 answered on 26 Jul 2021
4 answers
226 views

Hi, 

I have a Treelist filled with items + plus another textbox control.  The contents of these controls are just different views of the same list of fields.  As I move my mouse over the treelist, I'd like a mousemove event to fire so I can highlight the equivalent item in my textbox. 

How do I get a mouseover event to call my underlying C# code with the current mouse over row? 

Note, I currently have a column template with mousemove event in it.  That works, but requires very specific mouse locations.  I'd like it to be a full row trigger (just like your current mouseover highlighting).  I'd really prefer not to use a row template either as I want all the cool functionality you provide without it (expand/collapse, edit etc).  Is this possible?

I'm from a wpf background and love the idea of making web-based apps that can provide rich experiences to my users.  I'm really hoping that Blazor grant me this opportunity.

Cheers

 

 

Jason
Top achievements
Rank 1
Iron
 answered on 26 Jul 2021
1 answer
163 views
i have been running on the backend of a brand new project for media control, and prepared to start digging right into a ui to talk to my graphql api.

i would used asp.internet "lower back in the day", and had carried out a silverlight gui, but have not accomplished front-stop work in some time.

i am looking to decide how to choose from the cutting-edge country of the sector - blazor, asp.net core, and many others.

i'm a c # dev, so i would favor to do as a great deal of this as i will w / o desiring javascript help. https://1921681254.mx/

for a ui that looks incredibly similar to adobe bridge (underneath), could blazor paintings well for me today? i am privy to the component libraries from telerik and others, which in all likelihood could provide me a headstarthttps://100001.onl/
finsi
Top achievements
Rank 1
 updated question on 25 Jul 2021
1 answer
194 views
User is complaining the distinct list used for filtering is not sorted.  Is there a way to have them sorted?
Marin Bratanov
Telerik team
 answered on 23 Jul 2021
1 answer
209 views

Hello!

Consider the code bellow. I have an @ondblclick event on a card that sets a boolean value which  in turns controls the visible property of a Telerik RTE inside a foreach loop.

The problem is when I double click on card, all the RTEs become visible. How can I control the dblclick event to set the Visible property of the RTE inside the card I dblclick? Any hint will do.

I dont know if I am making any sense, but I can provide additional details if needed.


@foreach (var chapters in leaseContractDefaultTemplateChapters.OrderBy(s => s.DisplayOrder))
                                        {
                                            <MudContainer Fixed="true">
                                                <MudPaper Height="auto" Width="auto">
                                                    <MudCard @ondblclick="@OnChapterCardDoubleClick">
                                                        <MudCardHeader>
                                                            <CardHeaderContent>
                                                                <MudText Class="d-flex" Typo="Typo.h6">@chapters.Name</MudText>
                                                            </CardHeaderContent>
                                                            <CardHeaderActions>                                                                
                                                                <MudIconButton OnClick="@(async () => await GetComputedTemplateChapter())" Icon="@Icons.Material.Outlined.Functions" />                                                                
                                                                <MudIconButton OnClick="@OnSaveChapterClick" Icon="@Icons.Material.Filled.Save" Color="Color.Success" />
                                                            </CardHeaderActions>
                                                        </MudCardHeader>
                                                        <MudCardContent>
                                                            @if (rteVisible)
                                                            {
                                                                <TelerikEditor @ref="chapterEditor" @bind-Value="@chapters.HtmlString"
                                                                               Tools="@Tools"
                                                                               Height="300px">
                                                                </TelerikEditor>
                                                            }
                                                            else
                                                            {
                                                                @((MarkupString)chapters.HtmlString)
                                                            }
                                                        </MudCardContent>
                                                    </MudCard>
                                                </MudPaper>                     
                                            </MudContainer>
                                        }




Marin Bratanov
Telerik team
 answered on 22 Jul 2021
Narrow your results
Selected tags
Tags
+? more
Top users last month
Ambisoft
Top achievements
Rank 2
Iron
Pascal
Top achievements
Rank 2
Iron
Matthew
Top achievements
Rank 1
Sergii
Top achievements
Rank 1
Andrey
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Ambisoft
Top achievements
Rank 2
Iron
Pascal
Top achievements
Rank 2
Iron
Matthew
Top achievements
Rank 1
Sergii
Top achievements
Rank 1
Andrey
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?