Renaming a column makes column information disapear.
I have a table that has a feature where you can rename a column by using a text change event handler. So as a user is typing into a text box, the name of the column is being updated at the same time.
I have an issue where I type in information into a few cells, then I decide to rename the column. As soon as I type in the first letter, all the cells that have information in that column, disappear.
To me it looks like some binding issue, where the column mapping isn't translating properly between the GridGroupingControl Table and the Data Table.
This is where I've just added a column and then edited some cells.
This is when I go to rename the column, all the information disappears.
Below is how I've been updated the column names in the grid and the data table.
if (mTranslationsGrid.DataTable.Columns[originalHeaderText].ColumnName != updatedName)
{
mTranslationsGrid.DataTable.Columns[originalHeaderText].ColumnName = updatedName;
}
mTranslationsGrid.Grid.TableDescriptor.VisibleColumns[originalHeaderText].Name = updatedName;
mTranslationsGrid.Grid.TableDescriptor.Columns[originalHeaderText].MappingName = updatedName;
mTranslationsGrid.Grid.TableDescriptor.Columns[originalHeaderText].HeaderText = updatedName;
mTranslationsGrid.Grid.TableDescriptor.Columns[originalHeaderText].Name = updatedName;
Hi Adrian Negrillo,
We have analyzed your query and the code snippet you provided. It seems that you are attempting to change the column name based on what the user is typing into a text box. In the code you provided, you changed the HeaderText and Name properties value, but you also changed the MappingName property value. However, in the datatable, the mapping name is already assigned and has a corresponding value. The data in the GridGroupingControl is maintained based on the MappingName.
If you try to change the MappingName property, the table will not have that kind of MappingName and the changed MappingName will not have any data. As a result, the information in the column will disappear.
Kindly change the HeaderText and Name of the column as it will not have any impact on the data. we have provided sample for your reference , kindly refer the sample and let us know if you have any further concerns on this.
Code Snippet:
|
private void TextBox1_TextChanged(object sender, System.EventArgs e) { UpdatedName= this.textBox1.Text; gridGroupingControl1.TableDescriptor.VisibleColumns[0].Name = UpdatedName; gridGroupingControl1.TableDescriptor.Columns[0].HeaderText = UpdatedName; gridGroupingControl1.TableDescriptor.Columns[0].Name = UpdatedName;
} |
Image Reference:
|
|
Attachment: GridGroupingControl_Demo4_8_3f0f2b02.zip
Hey thanks for the reply however I'm faced with another issue, where if I update a cell in that column and then I add a new column. The information in the first set disappear.
Reproduction steps.
Create New Column > Rename Column and Modify Row Cell
Original Column Name: New Translation: 0
New Column Name: New Column
Add New Column > The modified cell data disappears.
My code for adding a column is below.
if (!_mGrid.TableDescriptor.Columns.Contains(columnName))
{
if (!_mGrid.TableDescriptor.Columns.Contains(columnName))
{
_mGrid.TableDescriptor.Columns.Add(columnName);
_mGrid.TableDescriptor.VisibleColumns.Add(columnName);
_mGrid.TableDescriptor.Columns[columnName].Appearance.ColumnHeaderCell.Borders.Bottom=newGridBorder(GridBorderStyle.Solid, Color.FromArgb(176, 176, 176), GridBorderWeight.Thin);
_mGrid.TableDescriptor.Columns[columnName].Appearance.ColumnHeaderCell.BackColor=SystemColors.ControlLight;
}
}
if (!_mDataTable.Columns.Contains(columnName))
{
DataColumnnewColumn=newDataColumn(columnName);
newColumn.Caption=columnName;
_mDataTable.Columns.Add(newColumn);
}
I've tried refreshing the control to see if that's worked but didn't do anything, so I'm not sure if I need to do something extra to hold the modified information.
Hi Adrian Negrillo ,
We have analyzed your query and prepared a sample based on the provided code snippet.
- We are modifying the cell in the existing column and adding a new column.
- First, create a new column, rename it, modify the cell in existing column, and add a value in the new column. In both cases mentioned above, the reported scenario is not replicating. It is working fine as expected. We have provided a sample for your reference.
Kindly review the sample. If you still encounter the issue, please modify the sample based on your scenario. This will help us proceed further.
Attachment: GridGroupingControl_Demo4_8_de4e024b.zip
Hey Sweatha,
Sorry for the late reply this has been resolved.
Thanks!
Hi Adrian Negrillo,
Glad that your issue is resolved! Please let us know if you need further assistance, we will be happy to help.
Regards,
Jayashree
- 5 Replies
- 3 Participants
-
AN Adrian Negrillo
- Jan 31, 2024 10:20 PM UTC
- May 20, 2024 09:16 AM UTC