EditorTemplate for in-cell TelerikGrid Edit not working properly for TelerikNumericTextBox?

1 Answer 55 Views
Grid NumericTextBox
Samuel
Top achievements
Rank 1
Iron
Samuel asked on 30 Jul 2024, 12:20 PM

I am trying to increase the number of decimal places that I can type into a cell using the in-cell editor on my TelerikGrid. It defaults to 2. When I try to use an EditorTemplate to pass a TelerikNumericTextBox component with 4 decimal places defined, it doesn't work. Not sure what I'm doing wrong...

See the code snippet below and the example png of what is generated.


<TelerikGrid Data=@SetupData EditMode="@GridEditMode.Incell" Pageable="true" PageSize="15" Height="500px"
             OnUpdate="@UpdateHandler" OnEdit="@EditHandler" OnDelete="@DeleteHandler" OnCreate="@CreateHandler" OnCancel="@OnCancelHandler" ConfirmDelete AutoGenerateColumns Sortable FilterMenuType="FilterMenuType.Menu">
    <GridToolBarTemplate>
        <GridCommandButton Command="Add" Icon="@SvgIcon.Plus">Add Setup</GridCommandButton>
        <GridSearchBox />
    </GridToolBarTemplate>
    <GridColumns>
        <GridAutoGeneratedColumns ColumnWidth="100px"></GridAutoGeneratedColumns>
        <GridColumn Field="@nameof(WelderSetupsModel.MinHeadGauge)">
           <EditorTemplate>
                @{
                    if(true)
                    {
                        var ctx = context as WelderSetupsModel;
                        <TelerikNumericTextBox @bind-Value="@ctx.MinHeadGauge" Decimals="4" />
                    }
           }
            </EditorTemplate>

        </GridColumn>
        <GridCommandColumn>
            <GridCommandButton Command="Delete" Icon="@SvgIcon.Trash"></GridCommandButton>
        </GridCommandColumn>
    </GridColumns>
</TelerikGrid>

1 Answer, 1 is accepted

Sort by
0
Samuel
Top achievements
Rank 1
Iron
answered on 30 Jul 2024, 02:19 PM

UPDATE:  

 

There looks to be a bug in the in-cell edit mode when you use AutoGenerated columns with defined GridColumns simultaneously. If I remove the AutoGenerated columns then the EditorTemplate works as expected. Adding the [Display(AutoGenerateField = false)] data annotation to the model for the property that I was tring to use an EditorTemplate with did not help either. Looks like we will have to manually define all grid-columns until this is fixed.  The code that works is shown below


<TelerikGrid Data=@SetupData EditMode="@GridEditMode.Incell" Pageable="true" PageSize="15" Height="500px"
             OnUpdate="@UpdateHandler" OnEdit="@EditHandler" OnDelete="@DeleteHandler" OnCreate="@CreateHandler" OnCancel="@OnCancelHandler" ConfirmDelete Sortable FilterMenuType="FilterMenuType.Menu">
    <GridToolBarTemplate>
        <GridCommandButton Command="Add" Icon="@SvgIcon.Plus">Add Setup</GridCommandButton>
        <GridSearchBox />
    </GridToolBarTemplate>
    <GridColumns>
        <GridColumn Field="@nameof(WelderSetupsModel.MinHeadGauge)">
            <EditorTemplate>
                @{
                    var ctx = context as WelderSetupsModel;
                    <TelerikNumericTextBox @bind-Value="@ctx.MinHeadGauge" Format="n4" Decimals="4" />
                }
            </EditorTemplate>

        </GridColumn>

        <!-- manually define all other grid columns here-->
        <GridCommandColumn>
            <GridCommandButton Command="Delete" Icon="@SvgIcon.Trash"></GridCommandButton>
        </GridCommandColumn>
    </GridColumns>
</TelerikGrid>
Tsvetomir
Telerik team
commented on 02 Aug 2024, 09:44 AM

Hello Samuel,

Thank you for the follow-up answer and the provided code snippets.

I tested the described behavior within this REPL link by creating an example with auto generated columns. As a result, it works as expected on my end - can edit the numeric value with 4 decimals. This leads me to think that I'm missing something from the actual configuration that will help me reproduce the scenario.

As a next step, could you modify the REPL to reproduce the issue you are facing and send it back to me for inspection? This will allow me to see the behavior firsthand and offer a suitable solution.

I look forward hearing back from you.

Kind Regards,

Tsvetomir

Tags
Grid NumericTextBox
Asked by
Samuel
Top achievements
Rank 1
Iron
Answers by
Samuel
Top achievements
Rank 1
Iron
Share this question
or