# Inline editing for DataGrid acting funny

**URL:** <https://forum.radzen.com/t/inline-editing-for-datagrid-acting-funny/5916>\
**Category:** Radzen.Blazor Components\
**Created:** [December 4, 2020, 6:32pm UTC](https://forum.radzen.com/t/inline-editing-for-datagrid-acting-funny/5916 "2020-12-04T18:32:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jserwatien](https://forum.radzen.com/letter_avatar_proxy/v4/letter/j/ec9cab/32.png) [@jserwatien](https://forum.radzen.com/u/jserwatien)\
**Post date:** [December 4, 2020, 6:32pm UTC](https://forum.radzen.com/t/inline-editing-for-datagrid-acting-funny/5916/1 "2020-12-04T18:32:20Z")

</div>

Has anyone seen this before? Only the last item on each page reacts when I try to use inline editing in a datagrid. When I invoke the edit on any other row, the event fires, but doesn't present the controls to make the edit. Only the last element on each page does. Even if I page to the next one it's the same thing.

Thanks

---

<div class="post-metadata">

**Author:** ![enchev](https://forum.radzen.com/user_avatar/forum.radzen.com/enchev/32/16_2.png) [@enchev](https://forum.radzen.com/u/enchev)\
**Post date:** [December 7, 2020, 7:14am UTC](https://forum.radzen.com/t/inline-editing-for-datagrid-acting-funny/5916/2 "2020-12-07T07:14:45Z")

</div>

Hey @jserwatien,

Our demo might help you:

> **[Blazor DataGrid - InLine Editing | Free UI Components by Radzen](https://blazor.radzen.com/datagrid-inline-edit)**
>
> This example demonstrates how to configure the Razden Blazor DataGrid for inline editing.

---

<div class="post-metadata">

**Author:** ![jserwatien](https://forum.radzen.com/letter_avatar_proxy/v4/letter/j/ec9cab/32.png) [@jserwatien](https://forum.radzen.com/u/jserwatien)\
**Post date:** [December 7, 2020, 2:29pm UTC](https://forum.radzen.com/t/inline-editing-for-datagrid-acting-funny/5916/3 "2020-12-07T14:29:33Z")

</div>

Thanks for the response. I took our code from your example. It's odd, because only the last one works, and even when I change the page, the last one is always working, but none of the others are...

---

<div class="post-metadata">

**Author:** ![enchev](https://forum.radzen.com/user_avatar/forum.radzen.com/enchev/32/16_2.png) [@enchev](https://forum.radzen.com/u/enchev)\
**Post date:** [December 7, 2020, 2:31pm UTC](https://forum.radzen.com/t/inline-editing-for-datagrid-acting-funny/5916/4 "2020-12-07T14:31:52Z")

</div>

If it works on our demo but not in your app you might need to check what’s different.

---

<div class="post-metadata">

**Author:** ![jserwatien](https://forum.radzen.com/letter_avatar_proxy/v4/letter/j/ec9cab/32.png) [@jserwatien](https://forum.radzen.com/u/jserwatien)\
**Post date:** [December 7, 2020, 4:04pm UTC](https://forum.radzen.com/t/inline-editing-for-datagrid-acting-funny/5916/5 "2020-12-07T16:04:26Z")

</div>

The code is different because our objects are different, but the rest is the same:

@page "/FixedRenewalRuleSetMaintenance"  
@using LetterAdmin.Entities;  
@inject IJSRuntime JSRuntime

@code {  
[Parameter]  
public FixedRenewalPageItems RuleItems { get; set; }  
public IList displayRules { get; set; }  
RadzenGrid detailGrid;  
private void FilterValues(object args)  
{

```
}
private void EditCard(MouseEventArgs args, string theID)
{
    var test = JSRuntime.InvokeAsync<string>("EditCard", theID);
}
void DisplayCard(MouseEventArgs args, string theID)
{
    var test = JSRuntime.InvokeAsync<string>("DisplayCard", theID);
}

protected override async Task OnInitializedAsync()
{
    RefreshGrid();
}
private void RefreshGrid()
{
    LetterAdmin.API.RenewalRuleService newService = new API.RenewalRuleService();
    RuleItems = new FixedRenewalPageItems();
    RuleItems = newService.GetFixedRenewalPageItems("jserwatien");
    displayRules = RuleItems.TheRules;
}
void Click(MouseEventArgs args)
{
    RefreshGrid();
    StateHasChanged();
}
void Search(string searchValue)
{
    displayRules = RuleItems.TheRules.Where(x => x.RenewalRuleDescription.ToUpper().Contains(searchValue.ToUpper())).ToList();
    StateHasChanged();
}
void EditRow(Rule theRule)
{
    detailGrid.EditRow(theRule);
}

void OnUpdateRow(Rule theRule)
{
    //dbContext.Update(order);

    //// For demo purposes only
    //order.Customer = dbContext.Customers.Find(order.CustomerID);
    //order.Employee = dbContext.Employees.Find(order.EmployeeID);

    // For production
    //dbContext.SaveChanges();
}

void SaveRow(Rule theRule)
{
    //ordersGrid.UpdateRow(order);
}
bool CollectionHasValues(int theCount)
{
    return theCount > 0;
}
void CancelEdit(Rule theRule)
{
    //ordersGrid.CancelEditRow(order);

    //// For production
    //var orderEntry = dbContext.Entry(order);
    //if (orderEntry.State == EntityState.Modified)
    //{
    // orderEntry.CurrentValues.SetValues(orderEntry.OriginalValues);
    // orderEntry.State = EntityState.Unchanged;
    //}
}

void DeleteRow(Rule theRule)
{
    //if (orders.Contains(order))
    //{
    // //dbContext.Remove<Order>(order);

    // // For demo purposes only
    // //orders.Remove(order);

    // // For production
    // //dbContext.SaveChanges();

    // //ordersGrid.Reload();
    //}
    //else
    //{
    // //ordersGrid.CancelEditRow(order);
}
void InsertRow()
{
    //theRules = theRules.ToList().Add(new .InsertRow(new Order());
}

void OnCreateRow(Rule newRule)
{
    
}

```

}

### Fixed Renewal Rule Set Maintenance

```
<RadzenDataList PageSize="18" WrapItems="true" AllowPaging="true" Data="@displayRules" TItem="RuleSet">
    <Template Context="RuleSet">
        <RadzenCard Style="width:400px; box-shadow:rgb(185, 203, 216) 5px 5px; outline:1px solid gray;">
            <div class="row">
                <div class="col-md-12" id="cardText_@RuleSet.FixedRenewalRuleSetKey" style="display:block">
                    <b style="font:bold 18px">@RuleSet.RenewalRuleDescription</b> (<a href="JavaScript: void(0);" onclick="EditCard('@RuleSet.FixedRenewalRuleSetKey');">edit</a>)
                    <br /><br />
                    <div>These customers will move to <b>@RuleSet.RateMappingColumn</b> of <b>@RuleSet.RateMappingValue</b></div>
                    <br /><div>Sort Order: <b>@RuleSet.SortOrder</b></div>
                    <br />
                </div>
                <div class="col-md-12" id="cardEdit_@RuleSet.FixedRenewalRuleSetKey" style="display:none">
                    <b style="font:bold 18px">@RuleSet.RenewalRuleDescription</b>
                    <br /><br />
                    <div>@RuleItems?.TheColumns?.Where(x => x.FixedRenewalColumnText == @RuleSet.RateMappingColumn)?.FirstOrDefault()?.InstructionText <RadzenDropDown AllowClear="true" TValue="string" @bind-Value="RuleSet.RateMappingColumn"
            FilterCaseSensitivity="FilterCaseSensitivity.CaseInsensitive" FilterOperator="StringFilterOperator.Contains" AllowFiltering="true"
            Data="@RuleItems.TheColumns" TextProperty="FixedRenewalColumnText" ValueProperty="FixedRenewalColumnText" Change="@(args => FilterValues(args))" /> 
            <RadzenDropDown AllowClear="true" TValue="string" @bind-Value="RuleSet.RateMappingValue"
                            FilterCaseSensitivity="FilterCaseSensitivity.CaseInsensitive" FilterOperator="StringFilterOperator.Contains" AllowFiltering="true"
                            Data="@RuleItems.TheValues.Where(x => x.FixedRenewalColumn == @RuleSet.RateMappingColumn)" TextProperty="FixedRenewalValue" 
                            ValueProperty="ItemCode" Visible="@CollectionHasValues(RuleItems.TheValues.Where(x => x.FixedRenewalColumn == @RuleSet.RateMappingColumn).Count())"/>
                    </div>
                    <br /><div>Sort Order: <input type="text" value="@RuleSet.SortOrder" /></div>
                    <br />
                    <RadzenButton style="margin-bottom: 10px" Text="Save" Click="@((args) => DisplayCard(args, RuleSet.FixedRenewalRuleSetKey.ToString()))"/>
                    <RadzenButton style="margin-bottom: 10px" Text="Cancel" Click="@((args) => DisplayCard(args, RuleSet.FixedRenewalRuleSetKey.ToString()))" />

                </div>
            </div>
            <div class="row">
                <div class="col-md-6">
                    <RadzenButton Icon="add_circle_outline" style="margin-bottom: 10px" Text="Add" Click="@InsertRow" />
                    <RadzenGrid @ref="detailGrid" AllowFiltering="false" AllowPaging="true" PageSize="12" AllowSorting="true" EditMode="DataGridEditMode.Single"
                                Data="@RuleSet.Rules" TItem="Rule" RowUpdate="@OnUpdateRow" Style="width:400px; position:center">
                        <Columns>
                            <RadzenGridColumn TItem="Rule" Property="FixedRenewalRuleKey" Title="ID" />
                            <RadzenGridColumn TItem="Rule" Property="FixedRenewalColumn" Title="Column">
                                <Template Context="Rule">
                                    @Rule.FixedRenewalColumn
                                </Template>
                                <EditTemplate Context="Rule">
                                    <RadzenTextBox @bind-Value="Rule.FixedRenewalColumn" Style="width:100%" Name="FixedRenewalColumn" />
                                    @*<RadzenDropDown AllowClear="true" TValue="int"
                    FilterCaseSensitivity="FilterCaseSensitivity.CaseInsensitive" FilterOperator="StringFilterOperator.Contains" AllowFiltering="true"
                    Data="@Rule" TextProperty="CompanyName" ValueProperty="CustomerID" @bind-Value="Rule.FixedRenewalColumnKey"/>*@
                                </EditTemplate>
                            </RadzenGridColumn>
                            <RadzenGridColumn TItem="Rule" Property="FixedRenewalValue" Title="Value">
                                <Template Context="Rule">
                                    @Rule.FixedRenewalValue
                                </Template>
                                <EditTemplate Context="Rule">
                                    <RadzenTextBox @bind-Value="Rule.FixedRenewalValue" Style="width:100%; display: block" Name="FixedRenewalValue" />
                                </EditTemplate>
                            </RadzenGridColumn>
                            <RadzenGridColumn TItem="Rule" Context="theData" Bubble="false" Filterable="false" Sortable="false" TextAlign="TextAlign.Center" Width="100px">
                                <Template Context="rule">
                                    <RadzenButton Icon="edit" Size="ButtonSize.Small" Click="@(args => EditRow(rule))">
                                    </RadzenButton>
                                </Template>
                                <EditTemplate Context="rule">
                                    <RadzenButton Icon="save" Size="ButtonSize.Small" Click="@((args) => SaveRow(rule))">
                                    </RadzenButton>
                                    <RadzenButton Icon="cancel" Size="ButtonSize.Small" ButtonStyle="ButtonStyle.Secondary" Click="@((args) => CancelEdit(rule))">
                                    </RadzenButton>
                                </EditTemplate>
                            </RadzenGridColumn>
                        </Columns>
                    </RadzenGrid>
                </div>
            </div>
        </RadzenCard>
    </Template>
</RadzenDataList>

```
