We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Regarding GridGroupingControl datasource update

Hi All,

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

24 Replies

HA haneefm Syncfusion Team August 7, 2007 11:41 PM UTC

Hi 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


SK Sathishkumar Kaliavaradhan August 8, 2007 05:04 AM UTC

Hi 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


RR Ramya R Syncfusion Team August 9, 2007 11:26 AM UTC

Hi SatishKumar,

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.


JH Jignesh H. Sodvadiya August 14, 2010 05:19 AM UTC

I have currently using Syncfusion GGC control to Display multiple datasouce data in tree level format.

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


MB Marcus Benz October 3, 2015 09:28 AM UTC

Hi,

I have the same Problem and tried to download the sample, but the link is broken.

Can you help me?

Best Regards
Marcus


SA Solai A L Syncfusion Team October 6, 2015 11:46 AM UTC

Hi Marcus/Sodvadiya,

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.



MB Marcus Benz October 22, 2015 06:11 PM UTC

Hi,

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


SA Solai A L Syncfusion Team October 23, 2015 12:42 PM UTC

Hi 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.


MB Marcus Benz October 24, 2015 11:59 AM UTC

Hi AL,

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


SA Solai A L Syncfusion Team October 26, 2015 11:41 AM UTC

Hi Marcus,

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.



MB Marcus Benz October 31, 2015 04:09 PM UTC

Hi AL,

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


SA Solai A L Syncfusion Team November 2, 2015 12:44 PM UTC

Hi 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.



MB Marcus Benz November 2, 2015 05:27 PM UTC

Hi AL,

thank you very much, that helps!

Best Regards
Marcus


SA Solai A L Syncfusion Team November 3, 2015 05:34 AM UTC

Hi 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.


JH Janine Herman September 5, 2017 07:40 AM UTC

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?



AR Arulpriya Ramalingam Syncfusion Team September 5, 2017 06:09 PM UTC

Hi Janine, 
 
Thanks for using Syncfusion products. 
 
We could understand your scenario. In order to update the changes of an Observable collection in Grid, the Table can be reloaded by using the Reload() method and the TableControl can be refreshed by using Refresh(). We have created a simple sample as per your requirement. Please make use of below code and sample, 
 
Code snippet 
 
 
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(); 
} 
 
 
 
Arulpriya 



UV Uldis Valneris February 21, 2018 10:07 AM UTC

Solution works, but is highly ineffective!

If I have a lot of rows and update just single value column on some rows - this solution will freeze everything up for a while. Because table will reload and repaint many times.
Is it possible to just reload a single row instead of reloading whole table?



AR Arulpriya Ramalingam Syncfusion Team February 22, 2018 04:24 PM UTC

Hi Uldis, 
 
Thanks for your update. 
 
We have analyzed your scenario at our end. The GridGroupingControl does not have support to reload some particular record alone. However, we would suggest you to refresh the added rows range for a better performance by using the RefreshRange() method. Please refer to the below code, 
 
Code example 
 
//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)); 
 
Please let us know, if you have any other queries. 
 
Regards, 
Arulpriya 



UV Uldis Valneris February 22, 2018 04:27 PM UTC

We get over this by setting value to both - bound datasource row and directly to grid cell with SetValue(...). This way we do not need to redraw grid at all.


AR Arulpriya Ramalingam Syncfusion Team February 23, 2018 04:51 AM UTC

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 



MJ Mariusz Juszkiewicz replied to Arulpriya Ramalingam September 12, 2018 04:03 AM UTC

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 


I have the same problem. I have used DataSet and Data table and grid is not getting refreshed with changes saved to (in my instance Access) data base with
TOGrid.Table.Reload();
TOGrid.Refresh();
TOGrid.TableControl.RefreshRange(GridRangeInfo.Row(TOGrid.TableModel.RowCount));
Has anyone resolved this?


MG Mohanraj Gunasekaran Syncfusion Team September 12, 2018 12:29 PM UTC

Hi Sathishkumar, 

Thanks for using Syncfusion product. 

To update the real time changes in underlying datasource (DataTable), you could use the DataTable.AcceptChanges and Table.Reload method. Please refer the following code example and the sample, 

Code example 
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(); 
 
 
Please refer the below KB link, 

Regards, 
Mohanraj G 



MJ Mariusz Juszkiewicz September 13, 2018 04:31 AM UTC

I have tried this example and it still does not work with ADO. Is there a full example with MS Access ADO connection?


MG Mohanraj Gunasekaran Syncfusion Team September 13, 2018 07:25 AM UTC

Hi Sathishkumar, 

Thank you for update. 
 
We suspect that you have tried to save the changes in binding database. If yes means, GridGroupingControl update the changes only in bounded collection. If you want to make this changes in your database, you could manually update your database using SourceListRecordChanging, SourceListRecordChanged and RecordValueChanged event in this event you can access if the records are being added, updated or deleted by using the Action property. Please refer to the following code example and the sample,    

 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();  
}  
  
  
  
Sample link: GridGroupingControl  
  
Note:  
We have provided the Sqlite related dll in bin folder. So, we have provided the sample with bin folder.  
 
Please let us know if we misunderstood your scenario. 
  
Regards,  
Mohanraj G  



Loader.
Live Chat Icon For mobile
Up arrow icon