I need to fill a grid line with information obtained after clicking ctrl + L.

I need to fill a grid line with information obtained after clicking ctrl + L.

ctrl + L is obtained through the rTalao.TableControlCurrentCellKeyUp event.

as a result I get a datatable with several columns that I want to insert into the grid.

I can't do this insert/update in the grid.

can someone help me, explaining to me how this can be done.


Thanks


18 Replies

AR Arulpriya Ramalingam Syncfusion Team December 1, 2021 02:07 PM UTC

Hi Ricardo, 
 
Greetings from Syncfusion. 
 
By default, the updated (adding, deleting and updating rows) changes from underlying datasource will be reflected in GridGroupingControl UI. We suspect that you are retrieving the current record value in TableControlCurrentCellKeyUp and trying to update it with some other data. If yes, the CurrentRecord.SetValue() method can be used to achieve this scenario and please make use of below code with sample. If your requirement is different, please revert to us with more details about your requirement. So that, we could analyze further and provide you a better solution. 
 
Example code 
 
//Event subscription 
gridGroupingControl1.TableControlCurrentCellKeyUp += GridGroupingControl1_TableControlCurrentCellKeyUp; 
//Event subscription 
 private void GridGroupingControl1_TableControlCurrentCellKeyUp(object sender, GridTableControlKeyEventArgs e) 
 { 
     if ((Control.ModifierKeys == Keys.Control) && e.Inner.KeyCode == Keys.L) 
     { 
         //To update current record. 
         e.TableControl.Table.CurrentRecord.SetValue("Country", "India"); 
     } 
 } 
 
 
Regards, 
Arulpriya Ramalingam 



RA Ricardo Abranches December 2, 2021 09:52 AM UTC

Hi,

thanks for your help. i will try this and let you know if it worked


Ricardo



AR Arulpriya Ramalingam Syncfusion Team December 3, 2021 06:08 AM UTC

Hi Ricardo, 
 
Thank you for the update. 
 
We will wait for you to test the provided solution and revert us. Please get back to us if you need any further assistance. 
 
Regards, 
Arulpriya Ramalingam 



RA Ricardo Abranches April 17, 2024 10:30 AM UTC

good morning

I am using this function to do ctrl + L on the grid

 Private Sub GridGroupingControl1_TableControlCurrentCellKeyUp(sender As Object, e As GridTableControlKeyEventArgs) Handles GridDoc.TableControlCurrentCellKeyUp

     Dim keyCode As Keys = Keys.KeyCode

     Dim rec As Record

     If e.TableControl.CurrentCell.ColIndex = 2 Then

         Select Case e.Inner.KeyCode

             Case Keys.L


                 If e.Inner.Control = True Then

                     Dim oLista As New cl_Listas

                     Dim sTmp As String

                     sTmp = oLista.ListaArtigos

                     If sTmp > "" Then


                         e.TableControl.Table.CurrentRecord.SetValue("Artigo", sTmp)

                         e.TableControl.Table.CurrentRecord.SetValue("Data", DateTime.Now)

                         e.TableControl.Table.CurrentRecord.SetValue("Cliente", tb_cliente.Text.ToString)

                         e.TableControl.Table.CurrentRecord.SetValue("ArtigoSage", "")

                         e.TableControl.Table.CurrentRecord.SetValue("Descr", "")

                         e.TableControl.Table.CurrentRecord.SetValue("Observacoes", "")

                         e.TableControl.Table.CurrentRecord.SetValue("Quantidade", "")

                         e.TableControl.Table.CurrentRecord.SetValue("Preco", "")


                         ' To trigger the CurrentCellValidating event.

                         e.TableControl.CurrentCell.Validate()

                     Else


                     End If

                     oLista = Nothing


                 End If


             Case Else

                 Exit Select

         End Select

     Else


     End If

 End Sub

but it gives this error "AddNew not called"

This happens when the grid has this symbol s1.png

When you have this symbol nothing happens  s2.png




SP Sreemon Premkumar Muthukrishnan Syncfusion Team April 18, 2024 07:26 PM UTC

Hi Ricardo Abranches,

We have checked the reported scenario. Unfortunately, we are unable to reproduce the mentioned error "AddNew not called." However, we observed that when pressing CTRL + L on the second column, the value changes correctly. But when entering any value in the cell and then pressing CTRL + L, the value does not change; it only changes after moving to another cell.

Could you please confirm whether the issue you are facing is that the value does not change when entering any value into the cell? We have attached the video reference below.

If we have misunderstood your requirement, could you please provide more information about the error you have mentioned? This will help us validate it and provide a solution as soon as possible.

Regards,
Sreemon Premkumar M.


Attachment: GridGroupingRebind_vBhGnnE8Vi_d26a9a3b.zip


RA Ricardo Abranches April 22, 2024 11:02 AM UTC

God morning

I have a gridGroupingcontrol with 1 data Source = select from sql Server table


P1.png

I do Ctrl + L and open a window where I choose a value

article. oRes = oArt.Artigo_get(sTmp)

by placing this value in the grid e.TableControl.Table.CurrentRecord.SetValue("Artigo", sTmp)

I get the error System.InvalidOperationException: 'AddNew not called'

If I execute an addNew before, I will end up with a new row.


P2.png

what I think is going on.

When a line has * at the beginning, it does not yet exist. That's why you need addNew. I must do something before trying to fill the line.


thanks



RA Ricardo Abranches April 22, 2024 11:05 AM UTC

If the DataSource doesn't have any rows, it works fine, but if it has some rows, it doesn't work anymore



SP Sreemon Premkumar Muthukrishnan Syncfusion Team April 23, 2024 05:51 PM UTC

Hi Ricardo Abranches, 

We are currently checking the reported issue. We need some time to validate, and we will provide you further update on or before April 25, 2024.

Regards,

Sreemon Premkumar M. 



SP Sreemon Premkumar Muthukrishnan Syncfusion Team April 25, 2024 03:53 PM UTC

Hi Ricardo Abranches,

We have checked this behavior in the source. Like you said, the reason for the exception being thrown is that when you try to set the value by pressing CTRL + L to add a new row, the row has not yet been created and it was described as '*'. The row gets created after you have entered a character into it. So it works fine without the exception.

We found that even with or without the rows, the behavior was the same. If there is no row in the control, when trying to set the value to the cells, it still throws the exception.

However, to meet this requirement of setting the value inside the 'add new row,' you need to call the GridTable.BeginEdit method to create the row before setting the value. Please find the code snippet below:

Code snippet:

if (e.Inner.Control)

{

    string sTmp = "New Artigo";

    if (!string.IsNullOrEmpty(sTmp))

    {

// before setting the value, you need to call the BeginEdit method to get the row for the Add new row.

        this.gridGroupingControl1.TableControl.Table.CurrentRecordManager.BeginEdit();

        e.TableControl.Table.CurrentRecord.SetValue("Name", "New Name");

        e.TableControl.Table.CurrentRecord.SetValue("Id", "22");

        e.TableControl.Table.CurrentRecord.SetValue("Start Date", "New Start Date");

        e.TableControl.Table.CurrentRecord.SetValue("Country", "New Country");

        e.TableControl.Table.CurrentRecord.SetValue("Ship City", "New Ship City");


        // To trigger the CurrentCellValidating event.

        e.TableControl.CurrentCell.Validate();

    }

We have prepared the sample based on this, please find it in the attachment.

Regards,
Sreemon Premkumar M.


Attachment: DataGrid_2015_Modified_56104c5e.zip


RA Ricardo Abranches April 25, 2024 06:35 PM UTC

YES !!!!

it worked, thank you

but if it is already in a filled row, if I change column 2 (with CTRL + L) it does not fill in the remaining columns, as it does in insertion mode




SP Sreemon Premkumar Muthukrishnan Syncfusion Team April 26, 2024 02:57 PM UTC

Hi Ricardo Abranches,

We have checked the reported issue wherein, when trying to set the value in an already filled row, the value was not set to the remaining columns other than column2. However, we observed that the values are properly updated in other columns but not in the second column. So, we suggest you check whether the current row was the add new row or not before calling the BeginEdit method. Please find the code snippet below.

Code snippet:

if(gridGroupingControl1.Table.DisplayElements[this.gridGroupingControl1.Table.CurrentRecord.GetRowIndex()].Kind ==

DisplayElementKind.AddNewRecord)

{

    this.gridGroupingControl1.TableControl.Table.CurrentRecordManager.BeginEdit();

}

If the issue still persists, and if we misunderstood the issue, could you please provide more information regarding the issue? We will validate and provide you with the proper solution.

Regards,
Sreemon Premkumar M.


Attachment: GridGroupingRebind_55KD5dGVax_add89bee.zip


RA Ricardo Abranches August 24, 2024 05:22 PM UTC

Hello,


I was struggling with GridGroupingControl, I didn't understand why your example worked well, but not in my project.

until I discovered this particularity

 Public Sub New()

     ...

     'gridGroupingControl1.GridVisualStyles = Syncfusion.Windows.Forms.GridVisualStyles.Office2016Colorful

     gridGroupingControl1.GridVisualStyles = Syncfusion.Windows.Forms.GridVisualStyles.Office2010Blue

...

 End Sub

If I choose Syncfusion.Windows.Forms.GridVisualStyles.Office2016Colorful it doesn't allow me to add rows to the grid.

If I choose Syncfusion.Windows.Forms.GridVisualStyles.Metro it doesn't allow me to add rows to the grid.


But if I choose Syncfusion.Windows.Forms.GridVisualStyles.Office2010Blue it works


Is there a way to overcome this situation?


The attached example demonstrates the problem.

Thank you



Attachment: GridGroupingControl_Rma_895577fb.zip


SP Sreemon Premkumar Muthukrishnan Syncfusion Team August 26, 2024 05:59 PM UTC

Hi Ricardo Abranches,

We are currently checking the reported issue with the sample you have provided. We need some time to validate it, and we will update you further details on or before August 28, 2024.

We appreciate your patience until then. 

Regards,

Sreemon Premkumar M. 



SP Sreemon Premkumar Muthukrishnan Syncfusion Team August 28, 2024 02:54 PM UTC

Hi Ricardo Abranches,

We have created a bug report for the reported issue “The 'Add new records' feature gets disabled when using the Office2016 and Metro themes in GridGroupingControl.”. We will include this fix in our upcoming Weekly NuGet release which is scheduled for September 24, 2024.

We will update you with the feedback details tomorrow.

Regards,

Sreemon Premkumar M.



SP Sreemon Premkumar Muthukrishnan Syncfusion Team August 30, 2024 02:09 PM UTC

Hi Ricardo Abranches

We have created a bug report for the reported issue “Add new row gets disabled when using the Office2016 and Metro themes in GridGroupingControl”. We will include this fix in our upcoming Weekly NuGet release which is scheduled for September 24, 2024.

You can track the status of this report through the following feedback link,

Feedback Link: Add new row gets disabled when using the Office2016 and Metro themes in GridGroupingControl in WinForms | Feedback Portal (syncfusion.com)

Note: The provided feedback link is private, and you need to login to view this feedback.

We will let you know once it is released. We appreciate your patience until then.

Disclaimer: Inclusion of this solution in the weekly release may change due to other factors including but not limited to QA checks and works reprioritization.

In the meantime, you can set the AllowNew property to true to display the 'Add New Row' after applying the theme. Please find the code snippet below.

gridGroupingControl1.GridVisualStyles = GridVisualStyles.Office2016Colorful;

 this.gridGroupingControl1.TableDescriptor.AllowNew = true;


Regards,

Sreemon Premkumar M.



SP Sreemon Premkumar Muthukrishnan Syncfusion Team September 24, 2024 02:48 PM UTC

Hi Ricardo Abranches,

We would like to let you know that Essential Studio Weekly NuGet packages (v27.1.50) has been published in nuget.org with the fix for the issue “Add new row gets disabled when using the Office2016 and Metro themes in GridGroupingControl”. Please let us know if you have any concerns in this.

Root Cause Details:

Initially, we had disabled the 'AllowNew' API in the GridGroupingControl for the Office2016 and Metro themes. We have now enabled this API for these themes in the GridGroupingControl.

Regards,
Sreemon Premkumar M.



RA Ricardo Abranches September 24, 2024 03:05 PM UTC

Thanks, i will test it




SP Sreemon Premkumar Muthukrishnan Syncfusion Team September 25, 2024 05:11 AM UTC

Hi Ricardo Abranches,

Please test and let us know the results. We will wait until we hear from you! 

Regards,

Sreemon Premkumar M.


Loader.
Up arrow icon