BoldSignA modern eSignature application with affordable pricing. Sign up today for unlimited document usage!
Hi Grzegorz,
Thanks for contacting Syncfusion Support.
We are unclear with your query. We need some clarification from your post. Can you please brief what you are mentioned for the term 1.4.3.2.12.1 NestedDropDown grid? It will be helpful for us to provide the solution at the earliest.
Regards,
Adhi
DataTable parentTable = GetParentTable();
DataTable childTable = GetChildTable();
DataTable grandChildTable = GetGrandChildTable();
DataTable greatGrandChildTable = GetGreatGrandChildTable();
DataTable greatGreatGrandChildTable = GetGreatGreatGrandChildTable();
DataSet ds=new DataSet();
ds.Tables.AddRange(new DataTable[] {parentTable,childTable,grandChildTable,greatGrandChildTable,greatGreatGrandChildTable});
ds.Relations.Add(new DataRelation("ParentToChild", ds.Tables[0].Columns["parentID"], ds.Tables[1].Columns["ParentID"]));
ds.Relations.Add(new DataRelation("ChildToGrandChild", ds.Tables[1].Columns["childID"], ds.Tables[2].Columns["ChildID"]));
ds.Relations.Add(new DataRelation("GrandChildToGreatGrandChild", ds.Tables[2].Columns["grandChildID"], ds.Tables[3].Columns["GrandChildID"]));
ds.Relations.Add(new DataRelation("GreatGrandChildToGreatGreatGrandChild", ds.Tables[3].Columns["greatGrandChildID"], ds.Tables[4].Columns["GreatGrandChildID"]));
this.gridDataBoundGrid1.DataSource=ds;
Please refer to the following dashboard sample, it shows how to add the nested grid in GridDataBoundGrid.
Dashboard sample:
<InstalledLocation>\Syncfusion\EssentialStudio\<VersionNo>\Windows\GridDataBound.Windows\Samples\ Hierarchy\GDBG Tree Lines Demo\CS
Regards,
Adhi
I have a GridDataBoundGrid in which I want to "*" up values from two different columns into a third column.
Example DataGridView:
Quantity UnitPrice value
2.00 2.00 4.00
3.00 2.00 6.00
5.00 2.00 10.00
I want to add (Quantity * UnitPrice in value),
just after entering values in Quantity & UnitPrice column or leaving current row.
.
whether this method is correct -
whether it is recommended :
void Grid_CurrentCellChanging(object sender, CancelEventArgs e)
{
int nField001 = this.order_DetailsGridDataBoundGrid.Binder.NameToField("Quantity");
int nField002 = this.order_DetailsGridDataBoundGrid.Binder.NameToField("UnitPrice");
if (this.order_DetailsGridDataBoundGrid.CurrentCell.ColIndex == nField001 + 1 | this.order_DetailsGridDataBoundGrid.CurrentCell.ColIndex == nField002 + 1)
{
try
{
int nField008 = this.order_DetailsGridDataBoundGrid.Binder.NameToField("ProductID");
int nField003 = this.order_DetailsGridDataBoundGrid.Binder.NameToField("value");
decimal unitPrice = Convert.ToDecimal(this.order_DetailsGridDataBoundGrid[this.order_DetailsGridDataBoundGrid.CurrentCell.RowIndex, nField002 + 1].Text );
decimal quantity = Convert.ToDecimal(this.order_DetailsGridDataBoundGrid[this.order_DetailsGridDataBoundGrid.CurrentCell.RowIndex, nField001 + 1].Text);
decimal value_1 = unitPrice * quantity;
this.order_DetailsGridDataBoundGrid[this.order_DetailsGridDataBoundGrid.CurrentCell.RowIndex, nField003 + 1].Text = "" + value_1 + "";
}
catch (Exception)
{
;
}
}
count me before the change . after the change should
Regards,
void gridDataBoundGrid1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
CurrencyManager cm = (CurrencyManager)this.BindingContext[this.gridDataBoundGrid1.DataSource];
if (e.ColIndex == 5 && e.RowIndex > 0 && e.RowIndex<this.gridDataBoundGrid1.Model.RowCount)
{
e.Style.CellValue = (Convert.ToDouble(((DataView)cm.List).Table.Rows[this.gridDataBoundGrid1.Binder.RowIndexToPosition(e.RowIndex)]["Quantity"]) * Convert.ToDouble(((DataView)cm.List).Table.Rows[this.gridDataBoundGrid1.Binder.RowIndexToPosition(e.RowIndex)]["Price"])).ToString();
}
}
Sample :
https://www.syncfusion.com/downloads/support/directtrac/general/ze/Combobox_modified-19204344601300285729.zip
Thanks & Regards,
AL.Solai.
Hi Grzegorz,
Thank you for your update.
Value column is not updated based on Quantity / Price | The Value Column is getting updated properly based on the value of Quantity and Price in current version 13.3. Please let us know the version that your using |
Format is not applied .NameToField("Quantity")].StyleInfo.Format = "N2" | Please refer the below image. The format is applied properly with the current version 13.3
|
Insert/Delete and Copy is not working | When your inserting a empty new record, it stores it as DBNull values which means that value does not exists. And for deleting a record, use RemoveRecords() from binder. Since, you have used insert method inside copy, the same DBNULL issue exist there also. Please try the below modified code example for insert/delete and copy.
Code Example : private void insertToolStripMenuItem_Click(object sender, EventArgs e) {
GridCurrentCell cc = this.order_DetailsGridDataBoundGrid.CurrentCell; DataRow tableRow1 = this.test009DataSet.Order_Details.NewRow(); tableRow1["OrderID"] = 10002; tableRow1["ProductID"] = "9"; tableRow1["UnitPrice"] = "9"; tableRow1["value"] = 2.44; tableRow1["Quantity"] = 5; this.test009DataSet.Order_Details.Rows.InsertAt(tableRow1, cc.RowIndex); // this.test009DataSet.Order_Details.AcceptChanges(); this.order_DetailsGridDataBoundGrid.Refresh(); this.order_DetailsGridDataBoundGrid.CurrentCell.MoveTo(cc.RowIndex, 0); }
private void deleteToolStripMenuItem_Click(object sender, EventArgs e) { GridCurrentCell cc = this.order_DetailsGridDataBoundGrid.CurrentCell; //https://help.syncfusion.com/windowsforms/gridgrouping/delete-collection-of-records-in-gridgroupingcontrol //we are subtracting one since, the record count will start from zero. this.order_DetailsGridDataBoundGrid.Binder.RemoveRecords(cc.RowIndex-1,cc.RowIndex-1); }
private void copyToolStripMenuItem_Click(object sender, EventArgs e) { GridCurrentCell cc = this.order_DetailsGridDataBoundGrid.CurrentCell;
this.order_DetailsGridDataBoundGrid.Model.CutPaste.Copy(); insertToolStripMenuItem_Click(sender, e); this.order_DetailsGridDataBoundGrid.CurrentCell.MoveTo(cc.RowIndex, cc.ColIndex); this.order_DetailsGridDataBoundGrid.Model.CutPaste.Paste();
} Modified sample : https://www.syncfusion.com/downloads/support/directtrac/general/ze/s_test21287255336-1146703141.zip |
Thanks,
AL.Solai.
//To copy selected range of cells to clipboard in GridDataBoundGrid.
bool
val =
this
.gridDataBoundGrid1.Model.CutPaste.CopyTextToClipboard(
this
.gridDataBoundGrid1.Selections.Ranges);
{
GridCurrentCell cc = this.order_DetailsGridDataBoundGrid.CurrentCell;
this.order_DetailsGridDataBoundGrid.Model.CutPaste.Copy();
insertToolStripMenuItem_Click(sender, e);
this.order_DetailsGridDataBoundGrid.CurrentCell.MoveTo(cc.RowIndex, cc.ColIndex);
this.order_DetailsGridDataBoundGrid.Model.CutPaste.Paste();
}
https://www.syncfusion.com/downloads/support/directtrac/general/ze/s_test2-1614462369-275609586.zip
4. additionally - how to save the base -
private void button1_Click(object sender, EventArgs e)
{
this.order_DetailsTableAdapter.Update(this.test009DataSet);
}
---does not save the new calculations "value"
Query | Response |
"value"- does not hold a defined format -- example does not work properly | We have modified the sample so that it achieves your requested scenario. Please refer the below sample. |
needs a copy - duplicate the contents of the selected row //copy move - insert a blank line paste - the contents of the selected row | The contents are not pasting because the current cell is not moving to the next row while pasting and also the selection row has to be changed while pasting. Please make use of the below code while copying. GridCurrentCell cc = this.order_DetailsGridDataBoundGrid.CurrentCell;
this.order_DetailsGridDataBoundGrid.Model.CutPaste.Copy(); insertToolStripMenuItem_Click(sender, e); this.order_DetailsGridDataBoundGrid.Selections.Clear(); this.order_DetailsGridDataBoundGrid.CurrentCell.MoveTo(cc.RowIndex + 1, cc.ColIndex); this.order_DetailsGridDataBoundGrid.Selections.Add(GridRangeInfo.Row(cc.RowIndex)); |
additionally - how to save the base - | You have to use the AcceptChanges() method before updating the table. Please refer the below code.
this.test009DataSet.AcceptChanges(); |
// Add expression field descriptor values at the end of the Expression Fields
this.gridGroupingControl1.TableDescriptor.ExpressionFields.AddRange(newSyncfusion.Grouping.ExpressionFieldDescriptor[] {
new Syncfusion.Grouping.ExpressionFieldDescriptor("Result", "([Quantity] *[UnitPrice])", "System.Double")});
void gridGroupingControl1_TableControlCurrentCellAcceptedChanges(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlCancelEventArgs e)
{
GridTableCellStyleInfo style = e.TableControl.GetTableViewStyleInfo(e.TableControl.CurrentCell.RowIndex, e.TableControl.CurrentCell.ColIndex);
GridTableCellStyleInfoIdentity id = style.TableCellIdentity;
Record rec = id.DisplayElement.GetRecord();
//modified value of value column
string modifiedvalue = rec.GetValue("Result").ToString();
}
Sample :
http://www.syncfusion.com/downloads/support/forum/120549/ze/s_test2-404028939
Regards,
AL.Solai.
To save the value to DB |
Expression field column is similar to unbound column. If you want to save this value to Db, you need to externally save it. You can get the Result column value in below two possible ways. 1. Using DrawCellDisplayText Code : void gridGroupingControl1_TableControlDrawCellDisplayText(object sender, GridTableControlDrawCellDisplayTextEventArgs e) { e.Inner.DisplayText; } 2. Using Style(this can be obtained using any events like current cell edit ,etc..) Code : GridTableCellStyleInfo style = e.TableControl.GetTableViewStyleInfo(e.TableControl.CurrentCell.RowIndex, e.TableControl.CurrentCell.ColIndex); GridTableCellStyleInfoIdentity id = style.TableCellIdentity; Record rec = id.DisplayElement.GetRecord(); //modified value of value column string modifiedvalue = rec.GetValue("Result").ToString(); |
Insert and Copy |
For insert you should use ForceImmediateSaveCellInfo in GGC similar to DirectSaveCellInfo Code Example : //Forces the GridGroupingControl to save the edited values while leaving the CurrentCell. foreach (FieldDescriptor col in this.gridGroupingControl1.TableDescriptor.Fields) |
Formats |
Please refer the below code example for reference. Code Example : this.gridGroupingControl1.TableDescriptor.Columns["Quantity"].Appearance.AnyRecordFieldCell.Format = "N2"; this.gridGroupingControl1.TableDescriptor.Columns["UnitPrice"].Appearance.AnyRecordFieldCell.Format = "C"; |
adding a new (*) line at the end of the table, |
Please use the below code to add the addnewrow at the bottom. Code Example : this.gridGroupingControl1.TopLevelGroupOptions.ShowAddNewRecordBeforeDetails = false; |
Copy and Paste |
Please include the below code for copy paste functionality this.gridGroupingControl1.TableModel.ClipboardCopy += new GridCutPasteEventHandler(TableModel_ClipboardCopy); this.gridGroupingControl1.TableModel.ClipboardCut += new GridCutPasteEventHandler(TableModel_ClipboardCut);
void TableModel_ClipboardCut(object sender, GridCutPasteEventArgs e) { this.gridGroupingControl1.TableControl.Model.CutPaste.Paste(); }
void TableModel_ClipboardCopy(object sender, GridCutPasteEventArgs e) { this.gridGroupingControl1.TableControl.Model.CutPaste.Copy(); }
|
private void copyToolStripMenuItem_Click(object sender, EventArgs e)
{
<code>
GridCurrentCell cc = this.gridGroupingControl1.TableControl.CurrentCell;
this.gridGroupingControl1.TableControl.Selections.Add(GridRangeInfo.Row(cc.RowIndex)); //add selection to the full row.
this.gridGroupingControl1.TableControl.Model.CutPaste.Copy();
<code>
}
Here is the modified sample,
s_test2f
Please let me know if I misunderstood your query.
Regards,
Christo
Query | Response |
save 2 - button1 - error "Concurrency violation: the UpdateCommand affected 0 of the expected 1 records." | We regret to let you know that we are unable to reproduce the reported issue. We tried to click the save button and no exception has been thrown. Could you please let us know whether we are missing something? |
when used- FieldChooser fchooser = new FieldChooser(this.gridGroupingControl1) check - then do not copy column "account" | This is the default behavior of copy paste functionality because only the visible contents can be copied and the hidden value will not be copied. So while unhiding the columns only the empty value will be displayed. |
this.gridGroupingControl1.TableDescriptor. Columns["Discount"].ReadOnly = true; - then do not copy columns "Discount" | We request you to make the ReadOnly property for the column “Discount” to false while copying the row and then again set the property to false to achieve this scenario. Please refer the below code. C#: this.gridGroupingControl1.TableDescriptor.Columns["Discount"].ReadOnly = false;
GridCurrentCell cc = this.gridGroupingControl1.TableControl.CurrentCell; this.gridGroupingControl1.TableControl.Selections.Add(GridRangeInfo.Row(cc.RowIndex)); //add selection to the full row. this.gridGroupingControl1.TableControl.Model.CutPaste.Copy();
insertToolStripMenuItem_Click(sender, e); this.gridGroupingControl1.TableControl.Selections.Clear(); this.gridGroupingControl1.TableControl.CurrentCell.MoveTo(cc.RowIndex + 0, cc.ColIndex); this.gridGroupingControl1.TableControl.Selections.Add(GridRangeInfo.Row(cc.RowIndex)); this.gridGroupingControl1.TableControl.Model.CutPaste.Paste(); this.gridGroupingControl1.TableControl.Selections.Clear();
|
save 2 - button1 - error "Concurrency violation: the UpdateCommand affected 0 of the expected 1 records." contextMenuStripEx1 - When you use copy, copy, insert , - an error |
As we said already we couldn’t able to reproduce the reported issue at our end. Could you please share us a screenshot or brief explanation of the scenario with a step by step replication procedure or a video. So, that it would be easy for us to provide a prompt solution. |
2. Or is your other solution to the problem |
By default, the Clipboard copy copies only the visible column. If you want to copy the hidden columns value, then you need to customize the copy operation at the application level. In Keydown event, when the key press is Ctrl+C Copy the selected record to clipboard from data source instead of Grid so that it doesn’t exclude the hidden column. |