This is a migrated thread and some comments may be shown as answers.

[Solved] add GridBinaryImageColumn at runtime

2 Answers 119 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mathias Köditz
Top achievements
Rank 1
Mathias Köditz asked on 03 Feb 2010, 08:35 AM

Hello,

my project work with dynamic column. If I add a GridBinaryImageColumn I can see it at the RadGrid. But if I start the Edit or the Insert I get an exception. In your documentation you insert javascript and _ItemCreated (…) function. I see a difference to add a GridBinaryImageColumn  to designtime and to runtime

GridBinaryImageColumnEditor editor = ((GridEditableItem)e.Item).EditManager.GetColumnEditor(“Upload”) as GridBinaryImageColumnEditor;

                        TableCell cell = (TableCell)editor.RadUploadControl.Parent; // add at rundtime = null

                        CustomValidator validator = new CustomValidator();

                        validator.ErrorMessage = "Please select file to be uploaded";

                        validator.ClientValidationFunction = "validateRadUpload";

                        validator.Display = ValidatorDisplay.Dynamic;

                        cell.Controls.Add(validator);

add function:

var gbic = new GridBinaryImageColumn();

            gbic.HeaderText = row.ShowName;

            gbic.ReadOnly = row.Edit; //true or false no difference

            gbic.DataField = row.ColumnName; //Upload

            gbic.UniqueName = row.ColumnName;

            gbic.ImageAlign = ImageAlign.NotSet;

            gbic.DataAlternateTextField = "Typ35";

            gbic.DataAlternateTextFormatString = "Image of {0}";

dataGrid.MasterTableView.Columns.Add(gbic);

 

 

(Add another column type it works)

Thanks for your help

(I see the same problem with a GridBinaryImageColumn (add at designtime) if ReadOnly = true and I AddNewRecord)

2 Answers, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 08 Feb 2010, 10:52 AM
Hello Mathias,

Your GridAttachmentColumn definition seems OK, only note that if you are dynamically adding columns to a statically created RadGrid (in the markup), you need to add your column to RadGrid.MasterTableView.Columns collection first, before setting it up. For more information, you can refer to the following RadGrid help article:

Programmatic creation

On the other hand, if you are dynamically creating your entire grid, make sure that the column is initialized and added to the master table's columns collection on every postback.

If you share some more sample code on the entire RadGrid declaration, we might be able to assist you better on this.

Regards,
Veli
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Veli
Telerik team
answered on 08 Feb 2010, 10:53 AM
Hello Mathias,

Your GridAttachmentColumn definition seems OK, only note that if you are dynamically adding columns to a statically created RadGrid (in the markup), you need to add your column to RadGrid.MasterTableView.Columns collection first, before setting it up. For more information, you can refer to the following RadGrid help article:

Programmatic creation

On the other hand, if you are dynamically creating your entire grid, make sure that the column is initialized and added to the master table's columns collection on every postback.

If you share some more sample code on the entire RadGrid declaration, we might be able to assist you better on this.

Regards,
Veli
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
Tags
Grid
Asked by
Mathias Köditz
Top achievements
Rank 1
Answers by
Veli
Telerik team
Share this question
or