Apply changes to child grid without moving confirm with enter

Hello,

I'm using GGC in mater-detail mode-
When I edit something in child table I need to press enter key to apply changes. How to to avoid this?
I want to changes be applied if user looses focus or let's say press Save button on toolbar. Is it possible?

3 Replies

SN Sindhu Nagarajan Syncfusion Team April 23, 2018 11:47 AM UTC

Hi Josip, 
 
Thanks for using Syncfusion products. 
 
In GridGroupingControl, by default, the modified cellvalues will be saved or committed automatically, when the current cell loses its focus or press the enter key. As per your requirement, to save the changes in a button click, CurrentCell.EndEdit() method can be used. Please make use of the below code and sample, 
 
Code Example 
private void Edit_Click(object sender, EventArgs e) 
{ 
    this.grid.TableControl.CurrentCell.EndEdit(); 
} 
 
 
 
Please let us know if you have any other queries. 
 
Regards, 
Sindhu  



JO Josip replied to Sindhu Nagarajan April 23, 2018 05:34 PM UTC

Hi Josip, 
 
Thanks for using Syncfusion products. 
 
In GridGroupingControl, by default, the modified cellvalues will be saved or committed automatically, when the current cell loses its focus or press the enter key. As per your requirement, to save the changes in a button click, CurrentCell.EndEdit() method can be used. Please make use of the below code and sample, 
 
Code Example 
private void Edit_Click(object sender, EventArgs e) 
{ 
    this.grid.TableControl.CurrentCell.EndEdit(); 
} 
 
 
 
Please let us know if you have any other queries. 
 
Regards, 
Sindhu  


Unfortunately, this doesn't work..

Here is my grid setup:

            gridNarucivanje.TopLevelGroupOptions.ShowFilterBar = true;
            filter.WireGrid(gridNarucivanje);

            GridExcelFilter gridExcelFilter = new GridExcelFilter();
            gridExcelFilter.EnableDateFilter = true;
            gridExcelFilter.WireGrid(this.gridNarucivanje);

            gridNarucivanje.TableOptions.AllowSelection = Syncfusion.Windows.Forms.Grid.GridSelectionFlags.None;
            gridNarucivanje.TableOptions.ListBoxSelectionMode = SelectionMode.One;
            gridNarucivanje.AllowProportionalColumnSizing = true;

            gridNarucivanje.ActivateCurrentCellBehavior = GridCellActivateAction.DblClickOnCell;
            gridNarucivanje.TableOptions.AllowSelection = Syncfusion.Windows.Forms.Grid.GridSelectionFlags.None;
            gridNarucivanje.TableOptions.ListBoxSelectionMode = SelectionMode.One;
            gridNarucivanje.AllowProportionalColumnSizing = true;
            this.gridNarucivanje.TopLevelGroupOptions.ShowAddNewRecordBeforeDetails = false;
            this.gridNarucivanje.TopLevelGroupOptions.ShowCaption = false;

parentToChildRelationDescriptor = new GridRelationDescriptor();
            parentToChildRelationDescriptor.ChildTableName = "Stavke";    // same as SourceListSetEntry.Name for childTable (see below)
            parentToChildRelationDescriptor.ChildTableDescriptor.TableOptions.ShowTableIndent = true;
            parentToChildRelationDescriptor.ChildTableDescriptor.AllowEdit = true;
            parentToChildRelationDescriptor.ChildTableDescriptor.AllowNew = true;
            parentToChildRelationDescriptor.RelationKind = RelationKind.RelatedMasterDetails;           
            parentToChildRelationDescriptor.RelationKeys.Add("UIDNarudzba", "UIDNarudzba");
            parentToChildRelationDescriptor.ChildTableDescriptor.Columns.Add("Opis", "Opis");
            parentToChildRelationDescriptor.ChildTableDescriptor.Columns.Add("Količina", "Kolicina");
            parentToChildRelationDescriptor.ChildTableDescriptor.Columns.Add("Naručeno", "Naruceno");
            parentToChildRelationDescriptor.ChildTableDescriptor.Columns.Add("Isporučeno", "Isporuceno");
            parentToChildRelationDescriptor.ChildTableDescriptor.Columns[0].HeaderText = "Opis";
            parentToChildRelationDescriptor.ChildTableDescriptor.Columns[1].HeaderText = "Količina";
            parentToChildRelationDescriptor.ChildTableDescriptor.Columns[2].HeaderText = "Naručeno";
            parentToChildRelationDescriptor.ChildTableDescriptor.Columns[2].Appearance.AnyRecordFieldCell.CellType = GridCellTypeName.CheckBox;
            parentToChildRelationDescriptor.ChildTableDescriptor.Columns[2].Appearance.AnyRecordFieldCell.CellValueType = typeof(int);
            parentToChildRelationDescriptor.ChildTableDescriptor.Columns[2].Appearance.AnyRecordFieldCell.ValueMember = "Naruceno";
            parentToChildRelationDescriptor.ChildTableDescriptor.Columns[2].Appearance.AnyRecordFieldCell.CheckBoxOptions.CheckedValue = "1";
            parentToChildRelationDescriptor.ChildTableDescriptor.Columns[2].Appearance.AnyRecordFieldCell.CheckBoxOptions.UncheckedValue = "0";
            parentToChildRelationDescriptor.ChildTableDescriptor.Columns[3].HeaderText = "Isporučeno";
            parentToChildRelationDescriptor.ChildTableDescriptor.Columns[3].Appearance.AnyRecordFieldCell.CellType = GridCellTypeName.CheckBox;
            parentToChildRelationDescriptor.ChildTableDescriptor.Columns[3].Appearance.AnyRecordFieldCell.CellValueType = typeof(int);
            parentToChildRelationDescriptor.ChildTableDescriptor.Columns[3].Appearance.AnyRecordFieldCell.ValueMember = "Isporuceno";
            parentToChildRelationDescriptor.ChildTableDescriptor.Columns[3].Appearance.AnyRecordFieldCell.CheckBoxOptions.CheckedValue = "1";
            parentToChildRelationDescriptor.ChildTableDescriptor.Columns[3].Appearance.AnyRecordFieldCell.CheckBoxOptions.UncheckedValue = "0";


            parentToChildRelationDescriptor.ChildTableDescriptor.ChildGroupOptions.ShowCaption = true;
            parentToChildRelationDescriptor.ChildTableDescriptor.AllowEdit = true;
            parentToChildRelationDescriptor.ChildTableDescriptor.AllowNew = true;
            parentToChildRelationDescriptor.ChildTableDescriptor.AllowRemove = true;

            gridNarucivanje.TableDescriptor.Relations.Add(parentToChildRelationDescriptor);

            gridNarucivanje.Engine.SourceListSet.Add("MyParentTable", new cDB().dbGetTable(sql_1, "MyParentTable"));
            gridNarucivanje.Engine.SourceListSet.Add("Stavke", bnd.GetData(sql_2));
            this.gridNarucivanje.DataSource = new cDB().dbGetTable(sql_1, "MyParentTable");

For automatic applying changes I was previously using:

              this.gridNarucivanje.Table.EndEdit();



SN Sindhu Nagarajan Syncfusion Team April 24, 2018 11:58 AM UTC

Hi Josip, 

Sorry for the inconvenience caused. 

We have prepared a sample and done the customizations as per your provided code snippet. As we updated earlier, the modified cellvalues will be saved or committed automatically, when the current cell loses its focus or when enter key is pressed. So, there is no need to apply the changes manually and please confirm us that whether you are trying to update the changes done in the grid to the underlying datasource or let us know your requirement clearly.  It would more helpful for us to provide the better solution at the earliest. 

Sample Link: GridGroupingControl 
Video Link: Video 

Regards, 
Sindhu  


Loader.
Up arrow icon