From 11af34efac888b10837071f2488712b83ac2432f Mon Sep 17 00:00:00 2001 From: KB Bot Date: Thu, 16 Oct 2025 13:40:07 +0000 Subject: [PATCH] Added new kb article grid-autofill-default-value-double-click --- ...rid-autofill-default-value-double-click.md | 97 +++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 knowledge-base/grid-autofill-default-value-double-click.md diff --git a/knowledge-base/grid-autofill-default-value-double-click.md b/knowledge-base/grid-autofill-default-value-double-click.md new file mode 100644 index 000000000..840f9f07c --- /dev/null +++ b/knowledge-base/grid-autofill-default-value-double-click.md @@ -0,0 +1,97 @@ +--- +title: Autofill a Default Value on Double-Click in Grid Edit Mode +description: Learn how to autofill a default value in a Telerik Grid cell during inline editing when double-clicking the cell. +type: how-to +page_title: Automatically Fill Default Value on Double-Click in Grid Inline Editing +meta_title: Automatically Fill Default Value on Double-Click in Grid Inline Editing +slug: grid-kb-autofill-default-value-double-click +tags: grid, gridcolumn, double-click, editing +res_type: kb +ticketid: 1700794 +--- + +## Environment + + + + + + + +
ProductGrid for Blazor
+ +## Description + +I want to autofill a default value for a specific cell in the Grid when double-clicking on it. The cell is in edit mode. + +## Solution + +To autofill a default value in the cell on double-click during inline editing, use the [`EditorTemplate`](slug:grid-templates-editor) of the Grid column and handle the `ondblclick` event. + +````Razor + + + + + @{ + var item = (Product)context; + +
+ +
+ } +
+
+ + + Edit + Save + Cancel + +
+
+ +@code { + private List Products { get; set; } + + private async Task OnGridUpdate(GridCommandEventArgs args) + { + var item = (Product)args.Item; + var index = Products.FindIndex(x => x.Id == item.Id); + + Products[index] = item; + } + + private void OnEditorDoubleClick(Product product) + { + product.Name = $"{product.Name} (edited)"; + } + + protected override void OnInitialized() + { + Products = new List() { + new Product() + { + Name = "Product Name", + Description = "Description text", + } + }; + + base.OnInitialized(); + } + + public class Product + { + public int Id { get; set; } + public string Name { get; set; } + public string Description { get; set; } + } +} +```` + +## See Also + +* [Grid Overview](slug:grid-overview) +* [Grid Editor Template](slug:grid-templates-editor)