Telerik Forums
UI for Blazor Forum
5 answers
603 views
Is it possible to create a custom column type (eg GridValidationColumn) for TelerikGrid?

I found the following example to validate a TelerikGrid cell (EditMode = GridEditMode.Incell).
https://feedback.telerik.com/blazor/1447439-is-there-a-way-to-implement-custom-validation-in-a-blazor-telerik-grid-when-pressing-save-update-command- button-if-not-is-there-plans-on-providing-custom-validation-as-a-feature-in-the-near-future
Starting from this example, in order not to repeat the validation code for each column, GridValidationColumn will need to have a default EditorTemplate that contains all the logic in the example. With the option to customize only the cell editor.
Marin Bratanov
Telerik team
 answered on 01 Apr 2021
3 answers
858 views
I have a grid that I added a column for a checkbox to select the row. I have multiple selection on. Now I want to respond to a button click and display the selected items in the grid. But I am finding that the act of clicking on the button deselects the selected items. How do I keep the keep the grid selection through a click on a button?
Marin Bratanov
Telerik team
 answered on 01 Apr 2021
1 answer
259 views

Hi,

I'm using the OnRead Event to do server side grouping and filtering. This is the function I use to retrieve the data:

DataSourceResult Result;
                if (_Request.Groups.Count > 0)
                {
                    argsCloned.Groups.Clear();
                    Result = await queriableData.ToDataSourceResultAsync(argsCloned);
                }
                else
                    Result = await queriableData.ToDataSourceResultAsync(_Request);


                DataEnvelope<T> dataToReturn = null;
                if (_Request.Groups.Count > 0)
                {
                    // Group again => Do grouping on local data
                    if (Result.Data != null)
                    {
                        Result = await Result.Data.ToDataSourceResultAsync(_Request);

                        dataToReturn = new DataEnvelope<T>
                        {
                            GroupedData = Result.Data.Cast<AggregateFunctionsGroup>().ToList(),
                            TotalItemCount = Result.Total
                        };
                        _GridData = dataToReturn.GroupedData.Cast<object>().ToList();
                    }
                }
                else
                {
                    dataToReturn = new DataEnvelope<T>
                    {
                        CurrentPageData = Result.Data.Cast<T>().ToList(),
                        TotalItemCount = Result.Total
                    };
                    _GridData = dataToReturn.CurrentPageData.Cast<object>().ToList();

                }

 

This works fine, the grouping is done and the aggregate data seems to be correct. But I don't see the data in the GroupFooterTemplate. If I Put a breakpoint inside the GroupFooterTemplate, the breakpoint is never hit.

<GridAggregates>    
                <GridAggregate Field="@nameof(TblCarrier.CarArtUid)" Aggregate="@GridAggregateType.Count" />
                <GridAggregate Field="@nameof(TblCarrier.CarQty)" Aggregate="@GridAggregateType.Sum" />
                <GridAggregate Field="@nameof(TblCarrier.CarWeightNetto)" Aggregate="@GridAggregateType.Sum" />
            </GridAggregates>

            <GridColumns>
                <GridColumn Field="@nameof(TblCarrier.CarUid)" FieldType="@(typeof(long))" Title="Uid" Width="150" Editable="false" Filterable="true">
                </GridColumn>

                <GridColumn Field="@nameof(TblCarrier.CarBarcode)" FieldType="@(typeof(long))" Title="Barcode" Width="150" Editable="false" Filterable="true"/>
                <GridColumn Field="@nameof(TblCarrier.CarTsCreation)" FieldType="@(typeof(DateTime))" Title="Ts Created" DisplayFormat="{0:dd/MM/yyyy HH:mm:ss.fff}" Width="200" Editable="false" Filterable="true"/>
                <GridColumn Field="@nameof(TblCarrier.CarTsLastMove)" FieldType="@(typeof(DateTime))" Title="Ts Moved" DisplayFormat="{0:dd/MM/yyyy HH:mm:ss.fff}" Width="200" Editable="false" Filterable="true"/>      
                <GridColumn Field="@nameof(TblCarrier.CarDescription)" FieldType="@(typeof(string))" Title="Description" Width="200" Editable="@(this.RoleLevel>=eRoles.Administrator)"  Filterable="true"/>
                <GridColumn Field="@nameof(TblCarrier.CarArtUid)" FieldType="@(typeof(string))" Title="Article ID" Width="200" Editable="@(this.RoleLevel>=eRoles.Developer)" Filterable="true">
                    <GroupHeaderTemplate>
                        @{
                            // you can use aggregates for other fields/columns by extracting the desired one by its
                            // field name and aggregate function from the AggregateResults collection
                            // The type of its Value is determined by the type of its field - decimal for the Salary field here
                            var ctx = context as GridGroupTemplateContext;
                            
                        }
                        Team Members: <strong>@context.Count</strong>
                    </GroupHeaderTemplate>      
                    <GroupFooterTemplate>
                        @{
                            // you can use aggregates for other fields/columns by extracting the desired one by its
                            // field name and aggregate function from the AggregateResults collection
                            // The type of its Value is determined by the type of its field - decimal for the Salary field here
                            var ctx = context as GridGroupTemplateContext;
                            
                        }
                        Team Members: <strong>@context.Count</strong>
                    </GroupFooterTemplate> 
                </GridColumn>

Best Regards

Marin Bratanov
Telerik team
 answered on 01 Apr 2021
1 answer
145 views

Hi,

I have  problem when I use aggregates on included fields in EF Core. Let me try to explain:

I have following queriable data:

 IQueryable<TblCarrier> queriableData = context.TblCarriers
                        .Include(x => x.CarPosU)
                        .Include(x => x.CarPosToNavigation)
                        .Include(x => x.CarArtU)
                        .AsQueryable();

 

The code herunder is working fine:

<GridAggregates>    
                <GridAggregate Field="CarArtUid" Aggregate="@GridAggregateType.Count" />
            </GridAggregates>

            <GridColumns>
                <GridColumn Field="CarUid" FieldType="@(typeof(long))" Title="Uid" Width="150" Editable="false" Filterable="true">
                </GridColumn>

                <GridColumn Field="CarBarcode" FieldType="@(typeof(long))" Title="Barcode" Width="150" Editable="false" Filterable="true"/>
                <GridColumn Field="CarTsCreation" FieldType="@(typeof(DateTime))" Title="Ts Created" DisplayFormat="{0:dd/MM/yyyy HH:mm:ss.fff}" Width="200" Editable="false" Filterable="true"/>
                <GridColumn Field="CarTsLastMove" FieldType="@(typeof(DateTime))" Title="Ts Moved" DisplayFormat="{0:dd/MM/yyyy HH:mm:ss.fff}" Width="200" Editable="false" Filterable="true"/>      
                <GridColumn Field="CarDescription" FieldType="@(typeof(string))" Title="Description" Width="200" Editable="@(this.RoleLevel>=eRoles.Administrator)"  Filterable="true"/>
                <GridColumn Field="CarArtUid" FieldType="@(typeof(long))" Title="Article" Width="200" Editable="@(this.RoleLevel>=eRoles.Developer)" Filterable="true">
                       <GroupHeaderTemplate>
                            Count: (@context.Count)
                        </GroupHeaderTemplate> 
                    
                    </GridColumn>

But when I try this, The context.count value is null:

<GridAggregates>    
                <GridAggregate Field="CarArtU.ArtErpCode" Aggregate="@GridAggregateType.Count" />
            </GridAggregates>

            <GridColumns>
                <GridColumn Field="CarUid" FieldType="@(typeof(long))" Title="Uid" Width="150" Editable="false" Filterable="true">
                </GridColumn>

                <GridColumn Field="CarBarcode" FieldType="@(typeof(long))" Title="Barcode" Width="150" Editable="false" Filterable="true"/>
                <GridColumn Field="CarTsCreation" FieldType="@(typeof(DateTime))" Title="Ts Created" DisplayFormat="{0:dd/MM/yyyy HH:mm:ss.fff}" Width="200" Editable="false" Filterable="true"/>
                <GridColumn Field="CarTsLastMove" FieldType="@(typeof(DateTime))" Title="Ts Moved" DisplayFormat="{0:dd/MM/yyyy HH:mm:ss.fff}" Width="200" Editable="false" Filterable="true"/>      
                <GridColumn Field="CarDescription" FieldType="@(typeof(string))" Title="Description" Width="200" Editable="@(this.RoleLevel>=eRoles.Administrator)"  Filterable="true"/>
                <GridColumn Field="CarArtU.ArtErpCode" FieldType="@(typeof(long))" Title="Article" Width="200" Editable="@(this.RoleLevel>=eRoles.Developer)" Filterable="true">
                       <GroupHeaderTemplate>
                            Count: (@context.Count)
                        </GroupHeaderTemplate> 
                    
                    </GridColumn>

 

The griddata is refreshed with the onread event

 DataEnvelope<T> dataToReturn = null;
                if (_Request.Groups.Count > 0)
                {
                    // Group again => Do grouping on local data
                    if (Result.Data != null)
                    {
                        Result = await Result.Data.ToDataSourceResultAsync(_Request);

                        dataToReturn = new DataEnvelope<T>
                        {
                            GroupedData = Result.Data.Cast<AggregateFunctionsGroup>().ToList(),
                            TotalItemCount = Result.Total
                        };
                        _GridData = dataToReturn.GroupedData.Cast<object>().ToList();
                    }
                }
                else
                {
                    dataToReturn = new DataEnvelope<T>
                    {
                        CurrentPageData = Result.Data.Cast<T>().ToList(),
                        TotalItemCount = Result.Total
                    };
                    _GridData = dataToReturn.CurrentPageData.Cast<object>().ToList();

                }

The grouped data seems to be fine. (See attached screenshot). The aggregate items key is CarArtU-ArtErpCode. Shouldn't that be CarArtU.ArtErpCode?

Thanks

 

 

 

Marin Bratanov
Telerik team
 answered on 01 Apr 2021
1 answer
97 views

Hi,

Does someone know if it is possible to extract the HTML code from the grid component? 

My goal is to investigate if there is a way of importing a grid into the editor component.

Much appreciated any thoughts.

Cheers

Marin Bratanov
Telerik team
 answered on 01 Apr 2021
1 answer
126 views

Hi,

Does anyone know if it is possible to insert a grid component (that is currently rendered on screen) into the editor?

My thoughts are that it should be possible to "convert" the grid into HTML code using the table tags.

Appreciate any thoughts or advice.

Cheers

Marin Bratanov
Telerik team
 answered on 01 Apr 2021
2 answers
262 views

Hi,

I have the next task to solve.
For Incell editing if the cursor is on the last row in the last editable field and the TAB key is pressed, a new row must be added as the last row and the cursor must be positioned in the first editable field of this row. The data source for the grid is of the ObservableCollection<> type.

I tried to write code on the OnUpdate and OnStateChanged events but without reaching the desired result.

Any help is welcome.

 

Vasile Lacatus

Advanced Software Solutions

Marin Bratanov
Telerik team
 answered on 01 Apr 2021
5 answers
1.3K+ views

Hi. 

I'm just wondering if there is a way to get a real-time chart like this. (or any other of the style)

I'm already made something "similar" with Telerik's charts. It is working but the component refresh does not look good. It redraws the series every time I add a new value. In my approach I tried using StateHasChanged () and Chart.Refresh () getting the same results.

Can you give me an idea of how to achieve that the series are not redrawn completely and only the last value is added in such a way we would obtain a smoother behavior?

Regards.
Ludwig.

Marin Bratanov
Telerik team
 answered on 31 Mar 2021
1 answer
278 views

Hello

 

Am trying to use this new component to get the browser size via below;

 

BlazorSizeKiller.razor

@foreach (var kv in MediaSizes)
{
    <TelerikMediaQuery Media="@(kv.Value)" OnChange="(() => UpdateCurrentSize(kv.Key))"></TelerikMediaQuery>
}

 

BlazorSizeKiller.razor.cs

public partial class BlazorSizeKiller
    {
        [Parameter] public int MaxScreenSize { get; set; } = 4000;
        [Parameter] public int MediaQuerySensitivity { get; set; } = 10;
        [Parameter] public int CurrentSize { get; set; }
        [Parameter] public EventCallback<int> CurrentSizeChanged { get; set; }
        readonly IDictionary<int, string> MediaSizes = new Dictionary<int, string>();


        protected override void OnParametersSet() => CreateList();

        private async Task UpdateCurrentSize(int media) => await CurrentSizeChanged.InvokeAsync(media);

        private void CreateList()
        {
            if (MediaSizes.Count == 0)
            {
                for (int i = 10; i < MaxScreenSize; i += MediaQuerySensitivity)
                {
                    MediaSizes.Add(i, "(max-width: " + i + "px)");
                }
            }
        }

    }

 

 

Is there a better way to do than this?

Or are there any problems with this method?

 

Cheers

Phil

 

Marin Bratanov
Telerik team
 answered on 31 Mar 2021
6 answers
544 views

After installing 2.23 into my Blazor WASM project, there's a js crash with the following stacktrace:

crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
      Unhandled exception rendering component: Could not find 'TelerikBlazor.getLocationHost' ('getLocationHost' was undefined).
      Error: Could not find 'TelerikBlazor.getLocationHost' ('getLocationHost' was undefined).
          at https://localhost:44320/_framework/blazor.webassembly.js:1:1287
          at Array.forEach (<anonymous>)
          at e.findFunction (https://localhost:44320/_framework/blazor.webassembly.js:1:1247)
          at b (https://localhost:44320/_framework/blazor.webassembly.js:1:2989)
          at https://localhost:44320/_framework/blazor.webassembly.js:1:3935
          at new Promise (<anonymous>)
          at Object.beginInvokeJSFromDotNet (https://localhost:44320/_framework/blazor.webassembly.js:1:3908)
          at Object.w [as invokeJSFromDotNet] (https://localhost:44320/_framework/blazor.webassembly.js:1:64232)
          at _mono_wasm_invoke_js_blazor (https://localhost:44320/_framework/dotnet.5.0.4.js:1:190800)
          at do_icall (<anonymous>:wasm-function[10596]:0x194e4e)
Microsoft.JSInterop.JSException: Could not find 'TelerikBlazor.getLocationHost' ('getLocationHost' was undefined).
Error: Could not find 'TelerikBlazor.getLocationHost' ('getLocationHost' was undefined).
    at https://localhost:44320/_framework/blazor.webassembly.js:1:1287
    at Array.forEach (<anonymous>)
    at e.findFunction (https://localhost:44320/_framework/blazor.webassembly.js:1:1247)
    at b (https://localhost:44320/_framework/blazor.webassembly.js:1:2989)
    at https://localhost:44320/_framework/blazor.webassembly.js:1:3935
    at new Promise (<anonymous>)
    at Object.beginInvokeJSFromDotNet (https://localhost:44320/_framework/blazor.webassembly.js:1:3908)
    at Object.w [as invokeJSFromDotNet] (https://localhost:44320/_framework/blazor.webassembly.js:1:64232)
    at _mono_wasm_invoke_js_blazor (https://localhost:44320/_framework/dotnet.5.0.4.js:1:190800)
    at do_icall (<anonymous>:wasm-function[10596]:0x194e4e)
   at Microsoft.JSInterop.JSRuntime.<InvokeAsync>d__15`1[[System.String, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext()
   at Telerik.Blazor.Components.Dialog.DialogBuilder.OnAfterRenderAsync(Boolean firstRender)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle)

 

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