I am trying to make the add a new row in my grid work the same as in the demo below but am not able to get the new row to be at the top of the grid and in edit mode as the demo does. Grid Incell editing Demo
The data is being retrieved from an OData endpoint.
When I click the add button a new record is created in the database and the grid refreshes, but I need to have that row be given the focus and be in edit mode. I would also like it at the top of the grid for editing as the demo does.
Why is my code not working as the demo does? What do I need to change to get it working like the demo?
My razor page:
<TelerikGrid
SelectionMode="@GridSelectionMode.Single"
TItem="@WarningVM"
OnRead="@ReadWarnings"
EditMode="@GridEditMode.Incell"
OnUpdate="@UpdateHandler"
OnEdit="@EditHandler"
OnCreate="@CreateHandler"
OnCancel="@OnCancelHandler"
Resizable="true"
Reorderable="true"
PageSize="15"
Navigable="true"
Pageable="true"
Sortable="true"
FilterMode="@GridFilterMode.FilterMenu">
<GridToolBar>
<GridCommandButton Command="Add" Icon="add">Add Warning</GridCommandButton>
</GridToolBar>
<GridColumns>
<GridColumn Title=" " Width="4em" Filterable="false">
<Template>
<span class="large-icons">
<TelerikIcon Icon="info-circle" Class="infoIcon"></TelerikIcon>
</span>
</Template>
</GridColumn>
<GridColumn Field="@(nameof(WarningVM.Id))" Width="7em" Editable="false"/>
<GridColumn Field="@(nameof(WarningVM.ValueType))" Title="Value Type"/>
<GridColumn Field="@(nameof(WarningVM.Value1))" Title="Value #1" />
<GridColumn Field="@(nameof(WarningVM.Value2))" Title="Value #2" />
<GridColumn Field="@(nameof(WarningVM.ReasonAdded))" Title="Reason Added"/>
<GridColumn Field="@(nameof(WarningVM.IsActive))" Title="Active" />
<GridCommandColumn Width="250px">
<GridCommandButton Command="Delete" Icon="delete"></GridCommandButton>
<GridCommandButton Command="Save" Icon="save" ShowInEdit="true"></GridCommandButton>
<GridCommandButton Command="Cancel" Icon="cancel" ShowInEdit="true"></GridCommandButton>
</GridCommandColumn>
</GridColumns>
</TelerikGrid>
My back end code:
public async Task ReadWarnings(GridReadEventArgs args)
{
ODataWarningsResponse data = await warningService.GetWarnings(args.Request);
args.Data = data.Warnings;
args.Total = data.Total;
}
private async Task UpdateHandler(GridCommandEventArgs args)
{
var test = await warningService.UpdateWarning((WarningVM)args.Item);
}
private async Task EditHandler(GridCommandEventArgs args)
{
var warningVM = (WarningVM)args.Item;
await warningService.UpdateWarning(warningVM);
}
private void CreateHandler(GridCommandEventArgs args)
{
WarningVM item = (WarningVM)args.Item;
warningService.UpdateWarning(item);
}
In certain situations I need to create forms based on hierarchical models. Initially let's assume something simple like:
Hello.
<TelerikGrid TItem="@MyModel" @ref="_myMainGridReference" OnRead="@OnReadHandler" OnRowDoubleClick="@OnGridDoubleClickHandler">
<GridColumns>
- Main grid columns here -
</GridColumns>
<DetailTemplate>
@{
/* Child component inside detailtemplate => how can I reference from the code behind? */
var ctex = context as JobViewModel;
<TelerikGrid @ref="??????" Data="@ctex.data" SelectionMode="@GridSelectionMode.Multiple">
<GridColumns>
- Detail grid columns here -
</GridColumns>
</TelerikGrid>
}
</DetailTemplate>
</TelerikGrid>
I'm trying to use the new Blazor Signature feature in a form but the pad isn't letting me draw. Nothing happens when I touch or use the mouse. Why is that?
<TelerikForm Model = "NewSignoff"
Even when I copy and paste the example to a new razor page, it doesn't work.
Help :)
How can I make it work and apply on a IQueryable if possible ?
If a value is "0" then I want to display an empty field. But if a value is greater that "0" I want to format it with 2 decimals.
I can not figure an easy way how.
Actually I have the choice between "#,###.##" and "#,##0.00". I have a lot of those fields so I need a kind of generic solution...
I'm displaying "live" data in a telerik blazor grid that is refreshed every 30 seconds by a timer from a database. I've tried following the examples to preserve the grid state, but all rows collapse after StateHasChanged(). I do not want to store the state in the local browser. The reason I would like this feature, is that I will be displaying a large amount of nested data, and would like to only allow the user to look at one record at a time (to simplify the interface). I'm not able to successfully preserve the expanded state. I have also tried
var state = Grid.GetState();
state.ExpandedItems = new List<MainModel> { mod };
await InvokeAsync(() => StateHasChanged());
await Grid.SetState(state)
But the state results in collapsed.