Regarding GridGroupingControl datasource update
I am using syncfusion version 4.4.0.51 and .NET 2.0
I have problem in GridGroupingControl while update datasource i need to update one of the check box field of UI should be checked or unchecked but it is not updating
Can you please tell me how do i update UI field?
Thanks and Regards
K.Sathishkumar
Here is a minimal sample that shows you "How to update checkboxcell in a grid cell?". Please refer this and let me know if this helps.
GroupCellCheckBox.zip
Below is a forum that shows you "How to add checkbox in a groupcaption cell of the grid?".
http://www.syncfusion.com/support/forums/message.aspx?&MessageID=55593
Best regards,
Haneef
you took my problem as reverse way but problem is i have one check box field in datasource bound column, i will update checkbox field of the datasource at runtime then i want to update same in checkbox field of GridGroupControl UI but my case not.
please tell me how do i solve this problem? if you can then send me some example also
waiting for your reply...
Thanks and Regards
K.Sathishkumar
Thank you for the update.
If your intention is to change the checkboxfield of a GridGroupingControl at runtime when the value of checkboxfield in the datasource is changed at runtime then it can be done as in the attached sample.
You can download the sample from the below link,
http://websamples.syncfusion.com/samples/Grid.Windows/F67014/main.htm
In this sample, a DataTable is created programmatically and used as datasource for the GridGroupingControl. The value of CheckBoxFields in the datacolumn of the datatable gets changed when the "Change DataSource Data" is clicked. Accordingly the GridGroupingControl also gets updated.
Kindly let me know whether this helps you.
Also please let me know if you have any queries.
Thanks & Regards,
Ramya.
My problem is that when Grid open & using thread update & Add new row in datasource then Grid Perant table Refresh but Child Table not refresh.....
Thanks and regards,
Jignesh H. Sodvadiya
I have the same Problem and tried to download the sample, but the link is broken.
Can you help me?
Best Regards
Marcus
To update the changes of parent /child table of gridgrouping control, use datatable.AccceptChanges(). Please refer the below code.
Code :
DataTable dt = this.gridGroupingControl1.DataSource as DataTable;
//Commits all the changes made to the table.
dt.AcceptChanges();
Thanks & Regards,
AL.Solai.
that doesn't work in my case. I have a Bindingsource as datasource. I cas use AcceptChanges on my DataTable behind the BindingSource, but that changes nothing.
When I enter a cell, changed in the DataTable, I see the new value. When I leave the cell, I see the old value again.
Best regards
Marcus
Thank you for your update.
Please refer the below provided sample. In this we have achieved your requirement to update the data source. If still your issue is not resolved. Replicate it in the sample provided below and get back to us. So, that it would be easy for us to provide a prompt solution. Please refer the below image to representing the value changes in 0X2 cell.
Sample :
http://www.syncfusion.com/downloads/support/forum/67014/ze/WindowsFormsApplication21_dtchanges1928997755
Thanks & Regards,
AL.Solai.
I think we are talking about different problems. I have changes in the datasource and they don't show in the grid.
It works if i use da DataTable as datasource. But I need a BindingSource as datasource. In this case I can see the changes only in the active row!
I have changed your sample to demonstrate the problem.
Thanks and best regards.
Marcus
Attachment: WindowsFormsApplication21_dtchanges1928997755_20151024_1ddca6cb.zip
Thank you for your update.
I guess there is misunderstanding. Please refer the below video, in that we have changed the value from 1 to 234 in cell 4X2 and 0.67 to 0.21 in 4X5 cell. After changing it I have check the value of grid cells in immediate window. I suspect that the issue what you mean is different from what I have provided. So, please share us a step by step replication procedure to locate the issue exactly.
Video : http://www.syncfusion.com/downloads/support/forum/67014/ze/valuechanged314889990
Thanks & Regards,
AL.Solai.
my problem is, that changes made in the datasource, don't show in the grid.
1st press this button:
that simulates loading new values from the database, made by someone else.
The result i would expect is this:
But this is what i get:
when i change the selected row:
You can see my problem when I use a BindingSource as datasource. The changed values are showing only in the selected row.
Of course is can get them when I access them with your way. But the user can't see the changes.
When I do a this.gridGroupingControl1.Reinitialize(); like in button4, the changes show in the grid, but I have to set the selected row an cell again.
That causes an annoying flickering.
When I use a DataTable as datasource, it works the way i would expect. But I am using a BindingSource in my project, to bind other controls, like textboxes, to the same datasource.
Thanks and best regards,
Marcus
Thank you for your update.
Please use Reload() of grid to update the modified values.
Code Example :
this.gridGroupingControl1.Table.Reload();
this.gridGroupingControl1.Refresh();
Thanks,
AL.Solai.
thank you very much, that helps!
Best Regards
Marcus
Thank you for your update.
We are glad to know that your issue has been resolved. Please let us know if you have any concerns in future regarding our control.
Thanks,
AL.Solai.
Hi,
I am running into a similar problem regarding the datasource update with GridGroupingControl
I am using Syncfusion Essential Studio 15.2.0.40
I have an observable collection that I am using as the datasource to the control
this.gridGroupingControl1.DataSource = observableCollection_test;This shows the correct data..
My issue is that when I modify the observable collection the changed data does not display in the control, it displays the same data that was originally loaded. If I close the application and restart it, the correct data will show in the grid.
i.e. I have a checkbox column and if I check that box it marks a flag as true and the grid will only display items that have this flag set to false, therefore when marked as true the observable collection updates that flag en re-queries the db to get the updated results, this is then passed back to the control as the datasource, but the original grid is displayed where that item is still false. If I close the application and re-open it, the information displayed to the user has updated and displays correctly.
I have tried the suggestions in this post already
DataTable dt = this.gridGroupingControl1.DataSource as DataTable;
// This just tells me that dt is null and throws error
dt.AcceptChanges();
// this does not give an error, but does not update the display to the user to show the correct info
this.gridGroupingControl1.Table.Reload();
this.gridGroupingControl1.Refresh();
but it does not work.
what am I doing wrong?
|
private void AddBtn_Click(object sender, EventArgs e)
{
collection.Add(new Data("54", "Category", "Desc" , "Date" ));
//To refresh the grid
this.gridGroupingControl1.Table.Reload();
this.gridGroupingControl1.TableControl.Refresh();
}
|
|
//To add the data in observable collection.
collection.Add(new Data("54", "Category", "Desc" , "Date" ));
this.gridGroupingControl1.Table.Reload();
//To refresh only the added rows range
this.gridGroupingControl1.TableControl.RefreshRange(GridRangeInfo.Row(gridGroupingControl1.TableModel.RowCount)); |
Hi Uldis,Thanks for your update.The idea to add and update the values both grid and data source can also be an optimal solution of the reported use case.Please let us know if you have any other queries.Regards,Arulpriya
TOGrid.Refresh();
TOGrid.TableControl.RefreshRange(GridRangeInfo.Row(TOGrid.TableModel.RowCount));
|
DataRow rowNew = table.NewRow();
rowNew["Dosage"] = 11;
rowNew["Drug"] = "newDrug";
rowNew["Patient"] = "newPat";
rowNew["Date"] = DateTime.Now;
table.Rows.Add(rowNew);
// must call this to add row in table
table.AcceptChanges();
// it reloads the datatable rows.
this.gridGroupingControl1.Table.Reload(); |
Code example
|
//Update db for Deletion.
void gridGroupingControl1_SourceListRecordChanging(object sender, Syncfusion.Grouping.RecordChangedEventArgs e)
{
if (e.Action == Syncfusion.Grouping.RecordChangedType.Removed)
{
String value = e.Record.GetValue("id").ToString();
string txtSQLQuery = "delete from mains where id =" + value;
ExecuteQuery(txtSQLQuery);
}
}
//Update db for addition.
void gridGroupingControl1_SourceListRecordChanged(object sender, Syncfusion.Grouping.RecordChangedEventArgs e)
{
if (e.Action == Syncfusion.Grouping.RecordChangedType.Added)
{
String column1Value = e.Record.GetValue("id").ToString();
string column2Value = e.Record.GetValue("desc").ToString();
string txtSQLQuery = "insert into mains ([id],[desc]) values ('" + column1Value + "','"+ column2Value + "')";
ExecuteQuery(txtSQLQuery);
}
}
//Update the db when modify the cell value.
void Table_RecordValueChanged(object sender, Syncfusion.Grouping.RecordValueChangedEventArgs e)
{
if (e.Record.Kind == Syncfusion.Grouping.DisplayElementKind.AddNewRecord)
return;
String columnName = e.Column;
Object val = e.Record.GetValue(columnName);
object unique = e.Record.GetValue("id");
if (val == null || unique == null)
return;
string value = val.ToString();
int topRowIndex = this.gridGroupingControl1.Table.Records[0].GetRowIndex();
int i = e.Record.GetRowIndex() - topRowIndex;
string txtSQLQuery = "update mains set " + columnName + " =\"" + value + "\" where id =" + unique.ToString();
ExecuteQuery(txtSQLQuery);
}
private void ExecuteQuery(string txtQuery)
{
SetConnection();
sql_con.Open();
sql_cmd = sql_con.CreateCommand();
sql_cmd.CommandText = txtQuery;
sql_cmd.ExecuteNonQuery();
sql_con.Close();
}
|
- 24 Replies
- 11 Participants
-
SK Sathishkumar Kaliavaradhan
- Aug 7, 2007 01:53 PM UTC
- Sep 13, 2018 07:25 AM UTC