Telerik Forums
UI for Blazor Forum
1 answer
562 views

Iam using Telerik Blazor grid in one of my application. The grid displays a list of items along with the  itemType. I need to implement a feature where users can select the items using a checkbox. I have done that using the GridCheckboxColumn. Now I want to limit the user to only select one item of a specific itemType. Such that the selected items will always belong to a distinct item type. No two items of the same itemType can be selected.

Is this possible in the current version? Could you point me to any resource which will allow me to achieve this?
I want to do this on the checkbox click event or something similar.

Marin Bratanov
Telerik team
 answered on 05 Apr 2021
10 answers
960 views

Hi,

I get an error when I click the filter button in this situation:

I have a colum with enum datatype. I filter the column on 1 of the enumeration values. After changing the filters, I save the gridstate to local storage. I use the system.text.json to serialize the gridstate. 

After refreshing the page, the filter loads correctly, the data is filtered on the database and the filter button is marked as used. When I click the button to change the filter, I get following error:

Unhandled exception in circuit '{CircuitId}'. (System.InvalidCastException: Unable to cast object of type 'System.Int16' to type 'System.Int32'.
   at Telerik.Blazor.Components.Common.Editors.TelerikEnumEditor.get_CurrentValue()
   at Telerik.Blazor.Components.Common.Editors.TelerikEnumEditor.BuildRenderTree(RenderTreeBuilder __builder)
   at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.RenderInExistingBatch(RenderQueueEntry renderQueueEntry)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessRenderQueue())

Thanks

 

Bert
Top achievements
Rank 1
Veteran
 answered on 02 Apr 2021
3 answers
1.6K+ views

Hi. I have a form that posts to a payment platform. I'd like to have a button that submits the form but also runs some other code, e.g. set a property to hide elements on the page.

 

Can I do this?   If so should I use ButtonType="ButtonType.Submit" plus an OnClick?  This doesn't seem to work.  Or should I use a ButtonType.Button and use some code to post the form?  (If so how could I do that)?

 

Thanks.

Dean

Stamo Gochev
Telerik team
 answered on 02 Apr 2021
1 answer
701 views

I am using the OnClick event of the menu to perform some actions and then navigate to the new page (using NavigationManager).

The problem I am having is that if the item I clicked on is in a drop down menu, the dropdown is still expanded after the navigation (note the menu is in the MainLayout).  

Is there anyway I can collapse the menu before (or after) it navigates?

Marin Bratanov
Telerik team
 answered on 01 Apr 2021
5 answers
575 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
825 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
255 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
138 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
96 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
118 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
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?