<EditForm Model="priceListDTO" OnValidSubmit="SendInformation">
<FluentValidator TValidator="PriceListCrudValidator" />
<fieldset disabled="@isDisabled">
<SfTab>
<TabItems>
<TabItem>
<ChildContent>
<TabHeader Text="Lista de precio" />
</ChildContent>
<ContentTemplate>
<AccordionComponent>
<div class="row align-items-center">
<div class="col-sm-6 col-md-4">
<div class="form-group row text-sm-left text-md-right">
<label class="col-form-label col-sm-4 my-auto">Nombre: </label>
<div class="col-sm-8 my-auto">
<SfTextBox @bind-Value="priceListDTO.Name"
TValue="string"
Placeholder="Nombre"
ShowClearButton=true
ShowSpinButton="false"
Format="0">
</SfTextBox>
<ValidationMessage For="() => priceListDTO.Name"></ValidationMessage>
</div>
</div>
</div>
</div>
<div class="row align-items-center">
<div class="col-md-4 my-auto">
<div class="form-group row text-sm-left text-md-right">
<label class="col-form-label col-sm-4 my-auto">Fecha Desde: </label>
<div class="col-sm-8 my-auto">
<SfDatePicker CssClass="allowonlydates" TValue="DateTime" @bind-Value="@priceListDTO.From"></SfDatePicker>
<ValidationMessage For="() => priceListDTO.From"></ValidationMessage>
</div>
</div>
</div>
<div class="col-md-4 my-auto">
<div class="form-group row text-sm-left text-md-right">
<label class="col-form-label col-sm-4 my-auto">Fecha Hasta: </label>
<div class="col-sm-8 my-auto">
<SfDatePicker CssClass="allowonlydates" TValue="DateTime?" @bind-Value="@priceListDTO.To"></SfDatePicker>
<ValidationMessage For="() => priceListDTO.To"></ValidationMessage>
</div>
</div>
</div>
</div>
</AccordionComponent>
</ContentTemplate>
</TabItem>
<TabItem>
<ChildContent>
<TabHeader Text="Precios" />
</ChildContent>
<ContentTemplate>
<AccordionComponent>
<SfGrid ID="Grid" @ref="@Grid"
Query="@GridQry"
TValue="PriceListItemDTO"
AllowPaging="true"
AllowSorting="true"
EnableAltRow="true"
Width="100%"
DataSource="@priceListItemDTO"
Toolbar="@ToolbarItems"
AllowTextWrap="true">
<GridEvents TValue="PriceListItemDTO"></GridEvents>
<GridEditSettings AllowAdding="true" AllowEditing="true" Mode="EditMode.Dialog" AllowDeleting="true"></GridEditSettings>
<GridPageSettings PageSize="10" PageSizes="true"></GridPageSettings>
<GridColumns>
<GridColumn Field=@nameof(PriceListItemDTO.Id) IsPrimaryKey="true" AllowEditing="false" Visible="false" HeaderText="Id" HeaderTextAlign="TextAlign.Center" TextAlign="TextAlign.Center" MinWidth="120" />
<GridColumn Field=@nameof(PriceListItemDTO.ProductId) HeaderText="Producto" HeaderTextAlign="TextAlign.Center" TextAlign="TextAlign.Center" MinWidth="300">
<EditTemplate Context="Productos">
<SfAutoComplete ID="ProductId"
TValue="string"
TItem="ProductDTO"
Placeholder="Seleccione un Producto"
DataSource="@listProductDTO"
@* @bind-Value="?" > I need binding Id value on child entity PriceListItemDTO.ProductId*@
<AutoCompleteFieldSettings Value="Name"></AutoCompleteFieldSettings>
</SfAutoComplete>
</EditTemplate>
</GridColumn>
<GridColumn Field=@nameof(PriceListItemDTO.From) HeaderText="Desde" HeaderTextAlign="TextAlign.Center" TextAlign="TextAlign.Center" MinWidth="150" />
<GridColumn Field=@nameof(PriceListItemDTO.Price) HeaderText="Precio" HeaderTextAlign="TextAlign.Center" TextAlign="TextAlign.Center" MinWidth="150" />
<GridColumn Field=@nameof(PriceListItemDTO.GrossPrice) HeaderText="Precio Bruto" HeaderTextAlign="TextAlign.Center" TextAlign="TextAlign.Center" MinWidth="150" />
<GridColumn Field=@nameof(PriceListItemDTO.InternalTax) HeaderText="Impuestos Internos" HeaderTextAlign="TextAlign.Center" TextAlign="TextAlign.Center" MinWidth="150" />
</GridColumns>
</SfGrid>
</AccordionComponent>
</ContentTemplate>
</TabItem>
</TabItems>
</SfTab>
We could see that you have rendered the Grid inside edit form. We would like to inform that edit form is a validator component and we should render only the input components. So it is not suggested to render the SfGrid inside editform. So kindly try the reported issue by placing the Grid outside the editform.
We have already documented this in the below UG section.
Please get back to us with more details if you still face difficulties.
Ok, i tried move the Grid outside from edit form but i still having trouble. My problem start before submit form.
I have childs data on the grid and I can't bind the Id field column from Autocomple. The Id data populate with "0" value.
Thank you for your inquiry. We have thoroughly reviewed your query, and in response, we have prepared a sample for you. You will find the attached sample that addresses your specific concern.
If, after reviewing the attached sample, you are still experiencing the issue or require further assistance, we kindly request you to attempt reproducing the problem within the provided sample.
<EditForm Model="@editorModel">
<div class="form-group"> <SfAutoComplete TValue="int?" TItem="EditorModel" DataSource="@GetIntDataItems" AllowFiltering=true ShowPopupButton=true @bind-Value=@value > <AutoCompleteFieldSettings Text="Name" Value="ID"></AutoCompleteFieldSettings> </SfAutoComplete> </div>
</EditForm>
@code { private EditorModel editorModel = new EditorModel();
public class EditorModel { public int ID { get; set; } public string Name { get; set; } }
public int? value = 2;
private List<EditorModel> GetIntDataItems = new List<EditorModel>() { new EditorModel() { Name = "Phython", ID = 0 }, new EditorModel() { Name = "JAVA", ID = 1 }, new EditorModel() { Name = "C#", ID = 2 }, new EditorModel() { Name = "Oracle", ID = 3 }, new EditorModel() { Name = ".NET", ID = 4 }, new EditorModel() { Name = "C++", ID = 5 } }; } |
We have created the sample based on your requirement. please find the sample here : https://www.syncfusion.com/downloads/support/common/4979/ze/AutoCompleteEditform_bf2abeb9.zip
Regards,
Gokul S