|
<SfGrid @ref="Grid" DataSource="@Orders" AllowPaging="true" Toolbar=@(new List<string>() { "Add", "Edit","Update","Cancel","Delete"})>
<GridEditSettings AllowAdding="true" AllowDeleting="true" AllowEditing="true" Mode="EditMode.Batch"></GridEditSettings>
<GridEvents OnRecordDoubleClick="RecordDoubleClickHandler" TValue="Order"></GridEvents>
..
<GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" Width="150">
<EditTemplate>
<SfDropDownList ID="CustomerID" TValue="string" TItem="Order" @bind-Value="@((context as Order).CustomerID)" DataSource="@Orders">
<DropDownListEvents ValueChange="DropDownOnChange" TValue="string"></DropDownListEvents>
<DropDownListFieldSettings Value="CustomerID"></DropDownListFieldSettings>
</SfDropDownList>
</EditTemplate>
</GridColumn>
..
</SfGrid>
@code{
private double RowIndex { get; set; }
public async Task DropDownOnChange(Syncfusion.Blazor.DropDowns.ChangeEventArgs<string> args)
{
await Grid.UpdateCell(RowIndex, "Freight", 2.1);
await Grid.UpdateCell(RowIndex, "CustomerID", args.Value);
}
public void RecordDoubleClickHandler(RecordDoubleClickEventArgs<Order> args)
{
RowIndex = args.RowIndex;
} |
Good Day,
I have a similar problem but I'm using the normal edit mode the batch editmode don't help me
I tried this code without success:
<SfGrid @ref="LignesGrid" DataSource="@ListeLignes"
Toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel" })">
<GridEvents OnRecordDoubleClick="RecordDoubleClickHandler" OnActionBegin="ActionBeginHandler" OnActionComplete="ActionCompleteHandler" TValue="LigneModel"></GridEvents>
<GridEditSettings ShowConfirmDialog="true" ShowDeleteConfirmDialog="true" AllowAdding="true" AllowDeleting="true" AllowEditing="true" Mode="EditMode.Normal">
</GridEditSettings>
<GridColumns>
<GridColumn Field="@nameof(LigneModel.Id)" IsPrimaryKey="true" Visible="false"/>
<GridColumn Field="@nameof(LigneModel.RefArticle)" Width="120">
<EditTemplate>
<SfAutoComplete TItem="ArticleModel" TValue="string" @bind-Value="@((context as LigneModel).RefArticle)" DataSource="ListeArticles">
<AutoCompleteFieldSettings Value="RefArticle"></AutoCompleteFieldSettings>
<AutoCompleteEvents TValue="string" TItem="ArticleModel" ValueChange="HandleRefArticleChanged"></AutoCompleteEvents>
</SfAutoComplete>
</EditTemplate>
</GridColumn>
<GridColumn Field="@nameof(LigneModel.Designation)" Width="120">
<EditTemplate>
<SfAutoComplete TItem="ArticleModel" TValue="string" @bind-Value="@((context as LigneModel).Designation)" DataSource="ListeArticles">
<AutoCompleteFieldSettings Value="Designation_fr"></AutoCompleteFieldSettings>
<AutoCompleteEvents TValue="string" TItem="ArticleModel" ValueChange="HandleRefArticleChanged"></AutoCompleteEvents>
</SfAutoComplete>
</EditTemplate>
</GridColumn>
<GridColumn Field="@nameof(LigneModel.Qte)" Width="120">
<EditTemplate>
<SfNumericTextBox @ref="QteCell" @bind-Value="@((context as LigneModel).Qte)" TValue="double?">
<NumericTextBoxEvents TValue="double?" ValueChange="HandleQteChanged"></NumericTextBoxEvents>
</SfNumericTextBox>
</EditTemplate>
</GridColumn>
<GridColumn Field="@nameof(LigneModel.Prix_Unitaire)" Width="120">
<EditTemplate>
<SfNumericTextBox @bind-Value="@((context as LigneModel).Prix_Unitaire)" TValue="decimal?">
<NumericTextBoxEvents TValue="decimal?" ValueChange="HandlePrixChanged"></NumericTextBoxEvents>
</SfNumericTextBox>
</EditTemplate>
</GridColumn>
<GridColumn Field="@nameof(LigneModel.Montant)" Width="120" >
</GridColumn>
</GridColumns>
</SfGrid>
private double RowIndex { get; set; }
public async Task HandleRefArticleChanged(Syncfusion.Blazor.DropDowns.ChangeEventArgs<string, ArticleModel> args)
{
try
{
await LignesGrid.UpdateCell(RowIndex, "Designation", args.ItemData.Designation_fr);
await LignesGrid.UpdateCell(RowIndex, "Qte", 1);
await LignesGrid.UpdateCellAsync(RowIndex, "Prix_Unitaire", args.ItemData.Prix_Unitaire);
await QteCell.FocusIn();
//LignesGrid.Refresh();
}
catch
{
}
}
public void ActionBeginHandler(ActionEventArgs<LigneModel> Args)
{
if (Args.RequestType.Equals(Syncfusion.Blazor.Grids.Action.Add) ||
Args.RequestType.Equals(Syncfusion.Blazor.Grids.Action.BeginEdit))
{
RowIndex = Args.RowIndex;
}
|
<GridColumn Field="@nameof(LigneModel.RefArticle)" Width="120">
<EditTemplate>
<SfAutoComplete TItem="ArticleModel" TValue="string" @bind-Value="@((context as LigneModel).RefArticle)" DataSource="ListeArticles">
<AutoCompleteFieldSettings Value="RefArticle"></AutoCompleteFieldSettings>
<AutoCompleteEvents TValue="string" TItem="ArticleModel" ValueChange=@(()=>HandleRefArticleChanged((context as LigneModel)))></AutoCompleteEvents>
</SfAutoComplete>
</EditTemplate>
</GridColumn>
public void HandleRefArticleChanged(LigneModel context)
{
//Set your values in the context
context.Designation = "DesignationChanged";
} |
|
<GridEvents OnActionComplete="OnActionComplete" TValue="Layer"></GridEvents>
..
public void OnActionComplete(ActionEventArgs<Layer> args)
{
if (args.RequestType.Equals(Action.Add) || args.RequestType.Equals(Action.BeginEdit))
{
//based on Add or Edit action disable the PreventRender
args.PreventRender = false;
}
}
|
Hi Palaniappan,
Thank's for your answer it's very helpful but I still need the args parameter for the event HandleRefArticleChanged
to pass the change values of the autocomplete
public async Task HandleRefArticleChanged(LigneModel context,
Syncfusion.Blazor.DropDowns.ChangeEventArgs<string, ArticleModel> args
)
{
//Set your values in the context
context.Designation = args.ItemData.Designation_fr;
context.RefArticle = args.ItemData.RefArticle;
context.Qte = 1;
context.Prix_Unitaire = await data.GetPrixArticleByTarif(args.ItemData.Id, (int)Entete.TarifId);
context.Montant = context.Prix_Unitaire;
await QteCell.FocusIn();
}
so how can I pass the second parameter in the :
ValueChange="@(()=>HandleRefArticleChanged((context as LigneModel),????)"
your help will be welcom
thank's
Best regards
got it it's:
ValueChange="@((args)=>HandleQteChanged((context as LigneModel),args))
Please Don't answer question
Thank's a lot
Good support
regards