Completed
Last Updated: 03 Dec 2024 15:01 by ADMIN
Igor
Created on: 25 Dec 2013 13:45
Category: Grid
Type: Bug Report
0
GridAutoCompleteColumn cannot be created during OnLoad event
GridAutoCompleteColumn columns cannot be created programmatically during OnLoad event, but only using the OnInit event.

In the attached sample, if you comment out 
panelOnInit.Controls.Add(gridOnInit);
and uncomment
panelOnLoad.Controls.Add(gridOnLoad);
when you click Edit in one row the following exception is thrown
Cannot create column with the specified type name: GridAutoCompleteColumn

But if you comment out 
panelOnLoad.Controls.Add(gridOnLoad);
and uncomment
panelOnInit.Controls.Add(gridOnInit);
the sample works

Note that if you change the GridAutoCompleteColumn for any other control type, for example GridHTMLEditorColumn, both methods will work.
Attached Files:
1 comment
ADMIN
Rumen
Posted on: 03 Dec 2024 15:01

Hi Igor,

After reviewing the behavior, we confirm that the GridAutoCompleteColumn can indeed be created programmatically during the OnLoad event if it is initialized and configured before being added to the control hierarchy.

        protected override void OnLoad(EventArgs e)
        {
            gridOnLoad = new RadGrid();
            gridOnLoad.AutoGenerateColumns = false;
            gridOnLoad.NeedDataSource += new GridNeedDataSourceEventHandler(grid_NeedDataSource);

            GridAutoCompleteColumn boundColumn = new GridAutoCompleteColumn();
            gridOnLoad.MasterTableView.Columns.Add(boundColumn);
            boundColumn.DataField = "Item";
            boundColumn.HeaderText = "Item";
            gridOnLoad.MasterTableView.Columns.Add(new GridEditCommandColumn());
            panelOnLoad.Controls.Add(gridOnLoad);

        }

While this scenario works, best practices suggest creating the grid and configuring its structure in the OnInit event to ensure consistent initialization. For reference, you can consult the Creating RadGrid Programmatically article.

Since the reported behavior functions as expected, this case will be marked as Completed. If you need further assistance, please feel free to open a new support ticket.

Thank you for your understanding.

Regards,
Rumen
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources