diff --git a/knowledge-base/form-keep-fields-order.md b/knowledge-base/form-keep-fields-order.md new file mode 100644 index 000000000..858893079 --- /dev/null +++ b/knowledge-base/form-keep-fields-order.md @@ -0,0 +1,105 @@ +--- +title: Keep Form Items Rendering Order after Show/Hide +description: How to keep the form item rendering order when changing the form item visibility. +type: how-to +page_title: Keep Form Items Rendering Order after Show/Hide +slug: form-kb-keep-fields-order +position: +tags: +ticketid: 1647539 +res_type: kb +--- + +## Environment + + + + + + + +
ProductForm for Blazor
+ +## Description + +This knowledge base article answers the following questions: + +* How do I keep the rendering order of Form items? +* Is it possible to toggle the visibility of a Form item and keep its rendering order instead of showing it as last? + +## Solution + +The `` tag doesn't render Form items directly. This tag is used only to register `` instances. The Form considers conditional field items, whose visibility may change, as the last items to be processed. + +To preserve the rendering place of each form item, you need to use the `TelerikFormItemRenderer`. + +````CSHTML + + + + + + + + + + + + + + + + + + + @{ + var formItems = formContext.Items.Cast(); + } + + @if (model.Field1 == 2) + { + + } + + + + +@code { + private FormModel model { get; set; } = new FormModel(); + + private List Items = new List() + { + new RadioButtonItem { ValueField = 1, TextField = "Item 1" }, + new RadioButtonItem { ValueField = 2, TextField = "Item 2" }, + new RadioButtonItem { ValueField = 3, TextField = "Item 3" }, + }; + + public class FormModel + { + public int Field1 { get; set; } + public int Field2 { get; set; } + public int Field3 { get; set; } + } + + public class RadioButtonItem + { + public string TextField { get; set; } + public int ValueField { get; set; } + } +} +```` + +## See Also + +* [Form Template for All Items]({%slug form-formitems-formitemstemplate%}) \ No newline at end of file