Editing

Good evening,

I'll describe what I need to do with the grid and state some questions. I'll also atach some files for you reproduce my cenario. You can ignore the "viewmodel" part.
I have a grid with some columns and two of them are editable.
When I type something in one editable cell, I have to update another cell and then jump to the next editable cell and automatically put it in edit mode. By now I can update the cell, but I'm not able to jump to the other cell and edit it.
I'm having also an erro when I try to get the index row with the "await Grid.GetSelectedRowIndexes()". It returns count 0 and null.
So, I want edit the "Produto.Codigo" column/cell, update the "Produto.Nome" column/cell and jump/edit the "FatorConversao" column/cell, when pressed tab or return.
By now I just put "Testando" in the "Produto.Nome" cell, but in the future I will get the value from the database.
Also, one of the editable fields is like this <GridColumn Field="Produto.Codigo" HeaderText="Código"  Width="150">
            <EditTemplate>
                    <SfTextBox ID="MeuID" @bind-Value="@((context as ProdutoFornecedorModel).Produto.Codigo)"></SfTextBox>
            </EditTemplate>
        </GridColumn>
But when I dobleclick that cell id doesn't put it in the edit mode, I have to click once more.

Thanks in advance!

Attachment: Project_Files_33b4158d.zip

3 Replies 1 reply marked as answer

RS Renjith Singh Rajendran Syncfusion Team May 26, 2021 11:19 AM UTC

Hi Társis, 

Greetings from Syncfusion support. 

Based on your scenario of using Batch mode of editing in grid, we suggest you to update the edited cell value(Produto.Codigo) and “Produto.Nome” cell values using EndEdit and SetRowData methods of Grid, instead of updating them into Datos. And also call the EditCell method inside DataBound event of Grid. We have prepared a sample(using dummy data) based on your shared codes, please download the sample from the link below, 
References :  

Please refer the highlighted codes below, 

<GridEvents CellSaved="CellSavedHandler" DataBound="DataBound" TValue="ProdutoFornecedorModel" />public async Task CellSavedHandler(CellSaveArgs<ProdutoFornecedorModel> args){    // Here you can customize your code    if (args.ColumnName == "Produto.Codigo")    {        var prodForn = Dados.FirstOrDefault(p => p.CdProdForn == args.Data.CdProdForn);        if (args.ColumnName == "Produto.Codigo" && !string.IsNullOrEmpty(args.Data.Produto.Codigo))        {            prodForn.Produto.Nome = "Testando";            prodForn.Produto.Codigo = args.Data.Produto.Codigo;            args.Data.Produto = prodForn.Produto;        }         var index = Dados.IndexOf(prodForn);        //Dados[index] = args.Data;        await Grid.SetRowData(prodForn.CdProdForn, args.Data);        await Grid.CallStateHasChangedAsync();          indexCell = await Grid.GetRowIndexByPrimaryKey(prodForn.CdProdForn);        //var index = await Grid.GetSelectedRowIndexes();        flag = true;        await Grid.EndEdit();    }}public async Task DataBound(){    if (flag)    {        flag = false;        await Grid.EditCell(indexCell, Grid.Columns[6].Field);    }}

Query : when I dobleclick that cell id doesn't put it in the edit mode, I have to click once more. 
We suggest you to ensure to provide proper ID values for the components inside EditTemplate to overcome this problem. For normal columns, the ID property should be same as Field name, and for complex columns, we suggest you to set the ID as like the below highlighted code, 

 
<GridColumn Field="Produto.Codigo" HeaderText="Código" TextAlign="@TextAlign.Right" Width="150"> 
    <EditTemplate> 
        <SfTextBox @ref="TextRef" ID="Produto___Codigo" ...></SfTextBox> 
    </EditTemplate> 
</GridColumn> 


 
Please get back to us if you need further assistance. 

Regards, 
Renjith R 


Marked as answer

Társis May 28, 2021 08:39 PM UTC

Thank you for your answer. It worked with the "return" key, but if I press the "TAB" key it doesn't edit the "FatorConversao" column/cell. How can I fix this?


VN Vignesh Natarajan Syncfusion Team May 31, 2021 11:56 AM UTC

Hi Társis,  
 
Thanks for the update.  
 
Query: “It worked with the "return" key, but if I press the "TAB" key it doesn't edit the "FatorConversao" column/cell. How can I fix this? 
 
We are not able to reproduce the reported issue in the provided sample. So kindly share more details about the issue you are facing.  
 
  1. Are you able to reproduce the reported issue in provided sample.
  2. If yes, share the video demonstration of the issue along with replication procedure.
  3. Otherwise share a simple issue reproducible sample.
  4. Share your Syncfusion NuGet package version details.  
 
It will be very helpful for us to validate the reported query at our end and provide a better solution as early as possible.  
 
Regards, 
Vignesh Natarajan 


Loader.
Up arrow icon