How do I call delete,update methods from the grid.

I have a grid with batch edit mode. Currently when i make some changes and click update, it doesn't actually update and it stays green highlighted even after i click yes to save changes. I think something may have affected this. Also how do i override the methods so when i click update or delete etc. it will make certain calls to the database with the updated data. I attached my grid code.


Attachment: New_Compressed_(zipped)_Folder_2ef53428.zip

7 Replies

CJ chris johansson September 19, 2020 09:49 PM UTC

Also for some reason when tabbing over in the grid from delivery location to item id it stops tabbing.  Is there a way to set the order?
also is there a way to navigate through the grid with arrows to each cell?


VN Vignesh Natarajan Syncfusion Team September 21, 2020 09:44 AM UTC

Hi Chris,  
 
Thanks for contacting Syncfusion support.  
 
Query: “it doesn't actually update and it stays green highlighted even after i click yes to save changes” 
 
We have analyzed your query and we would like to inform you that Batch editing is used to perform edit operation on multiple records at same time. And save all the changes in Grid upon single click (i.e.) Update Toolbar button. So the highlighted cell in Green color indicated that, there is some changes in cell which is not updated in Grid. Now clicking the update button will save the changes in grid.  
 
You have mentioned that cell appear to show green color even after clicking the yes button. We have ensured the reported issue at our end and we are not able to reproduce the reported issue. Kindly download the sample from below  
 
 
After referring the sample, if you are still facing the issue. kindly get back to us with following details.  
 
  1. Share your Grid code example.
  2. Are you facing any exception / error in browser console while saving the changes?
  3. Share the more details about your query.
  4. If possible try to reproduce the reported issue with provided sample and revert back to us.
 
Above requested details will be helpful for us to validate the reported query at our end and provide solution as early as possible.       
 
Query: “ Also how do i override the methods so when i click update or delete etc. it will make certain calls to the database with the updated data. I attached my grid code. 
 
We suggest you to achieve your requirement (to save the changes in Database) using OnBatchSave event of the Grid. This event will be triggered when saving all the changes (as a whole) in Grid. In the event argument we can get the changes performed in Grid, like changed record, added record, deleted records etc. Using these value, we can update the changes in Database. 
 
Refer the below code example.  
 
<SfGrid DataSource="@Orders" AllowPaging="true" Toolbar="@(new List<string>() { "Add""Delete""Update""Cancel" })"> 
    <GridEvents OnBatchSave="OnSave" TValue="Order"></GridEvents> 
    <GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="EditMode.Batch"></GridEditSettings> 
. . . . . . 
</SfGrid> 
  
@code{ 
    public List<Order> Orders { getset; } 
    public void OnSave(BeforeBatchSaveArgs<Order> Args) 
    { 
        var BatchChanges = Args.BatchChanges; 
        if(BatchChanges.AddedRecords.Count > 0) 
        { 
            //Insert data into your database 
        } 
        if(BatchChanges.ChangedRecords.Count > 0) 
        { 
            //update changes into your database 
        } 
        if(BatchChanges.DeletedRecords.Count > 0) 
        { 
            //delete record from your database 
        } 
    } 
 
Refer our UG documentation for your reference 
 
 
Query: “Is there a way to set the order? also is there a way to navigate through the grid with arrows to each cell? 
 
Yes we can navigate through the each cell in Grid using arrow keys once the cell is selected. While editing a cell using batch edit mode, tab key is used to navigate the next cell and perform edit operation in next cell. Are you facing any issue while using tab key. Or do you want to change the tab behavior to navigate from second column to 4th column as example?. Kindly confirm do you want to achieve above behavior?.  
 
If not kindly share more details about your requirement along with video demonstration.  
 
Regards, 
Vignesh Natarajan 



CJ chris johansson September 21, 2020 03:59 PM UTC

Thanks, the on save method works for overriding the toolbar. The issue about updating in batch mode and the green not disappearing I cannot figure out. I attached my index and the classes. The data gets called from an rest service upon initialization. I even removed some columns and basically just put one column in a bare bones grid with my Data source and it still does not work.  Interesting thing is the cancel does work and it removes the green.

Attachment: FDIChemicalOrderTable_65c5514.zip


CJ chris johansson September 21, 2020 09:19 PM UTC

The issue is i cannot tab from delivery location column to itemid .. which is the next column in the grid.
it basically goes to my tree and starts over with items at the top... how can i fix this to make it tab from delivery to itemid. I  attached my code in this thread.




VN Vignesh Natarajan Syncfusion Team September 22, 2020 07:39 AM UTC

Hi Chris,  
 
Thanks for sharing the details.  
 
Query: “The issue about updating in batch mode and the green not disappearing I cannot figure out. . 
 
We have analyzed the provided code example and found that you have not defined the PrimaryKey column in Grid. To Perform CRUD action in Grid, IsPrimaryKey property must be defined to any one of the available column whose value is unique. Based on the primarykey value only changes will be saved in Grid.  
So we suggest you to define the IsPrimaryKey property to any one of the column whose value is unique. Refer our UG documentation for your reference 
 
 
Query: “it basically goes to my tree and starts over with items at the top... how can i fix this to make it tab from delivery to itemid. I  attached my code in this thread. 
 
We have analyzed your query and we are able to reproduce the reported behavior at our end while preparing a sample using your code example. We suggest you to resolve the issue by defining the ID property of ComboBox control in EditTemplate same as GridColumn Field property.  
 
Refer the below code example.  
 
<GridColumn Field=@nameof(FDIChemicalOrderLine.FSDeliveryLocationIdHeaderText="Delivery Location" TextAlign="TextAlign.Right" EditType="EditType.DropDownEdit" AutoFit="true"> 
     <EditTemplate> 
  
         <SfComboBox @ref="comboboxLocationAddress" ID="FSDeliveryLocationId" TValue="string" width="300" TItem="FDILocationAddress" @bind-Value="(context as FDIChemicalOrderLine).FSDeliveryLocationId" Placeholder="e.g. 02-36-001-13W2" CssClass="e-multi-column" DataSource="@locationAddresses" AllowFiltering="true" Query="@locationQuery" PopupWidth="400px"> 
. . . . . . . . .  
         </SfComboBox> 
     </EditTemplate> 
 </GridColumn> 
  
Kindly get back to us if you have further queries.   
 
Regards, 
Vignesh Natarajan   



CJ chris johansson September 23, 2020 09:14 PM UTC

Thank you the primary key and tabbing worked when entering in the ID properly.  Last thing when I tab to the end of all the columns such as the Name column for example, it doesn't go to the next line. Instead it goes back to the tree.. Is there a way to force it to the next line by default? 


VN Vignesh Natarajan Syncfusion Team September 24, 2020 05:31 AM UTC

Hi Chris, 
 
Thanks for the update.  
 
Query: “Instead it goes back to the tree.. Is there a way to force it to the next line by default? 
 
We suggest you to achieve your requirement using AllowNextRowEdit property of GridEditSettings. When AllowNextRowEdit property is enabled, clicking on tab with focus is on last column will move the edit action next row.  
 
Refer our API documentation for your reference 
 
 
Kindly get back to us if you have further queries.   
 
Regards,
Vignesh Natarajan
 


Loader.
Up arrow icon