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

Examples of inheriting from GridDropDownColumn

7 Answers 102 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Pether Wiklander
Top achievements
Rank 2
Pether Wiklander asked on 27 Oct 2008, 02:08 PM
Hi,

I would like to be able to reuse some columns throughout my project. Is there any tutorials on how to inherit from i.e. the GridDropDownColumn?
I've been experimenting on overriding CreateDefaultColumnEditor and creating the data source there. Is this the way to go?

Best regards,
Pether Wiklander

7 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 28 Oct 2008, 08:06 AM
Hello Pether,

You can go through the following help link which explains on how to inherit columns. The code sample given in the link shows how to inherit from a BoundColumn,so you can add to it by probably checking if the column is in EditMode and then access the GridEditableItem and then modify the editor.
Inheriting grid columns

You can also refer to the following help link to ubnderstand  how to bind the GridDropDownColumnEditor to a datasource.
Adding GridDropDownColumn option on insert/edit

Hope these hints lead you to the right track.
Thanks
Princy.


0
Pether Wiklander
Top achievements
Rank 2
answered on 28 Oct 2008, 09:08 AM
Hi,

I don't know if the "Customizing the options for GridDropDownColumn on editing" example is old since
editor.DropDownListControl.SelectedValue = "2";
isn't valid. Am I missing something?

I'm interested in using that method but how can I determine which value that should be selected in the DropDownList?

// Pether


0
Sebastian
Telerik team
answered on 28 Oct 2008, 09:13 AM
Hello Pether,

You should be able to set SelectedValue or SelectedIndex for the dropdown editor as shown in the help topic linked by Princy. Here is its ASP.NET AJAX equivalent:

http://www.telerik.com/help/aspnet-ajax/grdcustomizeconfiguregriddropdowncolumn.html

Best regards,
Stephen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Pether Wiklander
Top achievements
Rank 2
answered on 28 Oct 2008, 09:27 AM
Hi,

What is wrong with the code example is that GridDropDownColumnEditor doesn't have a DropDownListControl property. I think it should be
editor.SelectedValue = "2";
and not
editor.DropDownListControl.SelectedValue = "2";

Please correct me if I'm wrong.

I'm still confused concerning how to use the GridDropDownColumn when I'm using a business method to retreive the data to fill the DropDownList. Are there any examples on how to do this. When I'm trying the first value in the lists are always selected no matter the value of DataField.

// Pether
0
Shinu
Top achievements
Rank 2
answered on 28 Oct 2008, 09:50 AM
Hello Pether,

Try using the following code to set a selected value for the dropdownlist control in the column editor.
editor.DropDownListControl.Items.FindByValue("2").Selected = true

Thanks
Shinu.
0
Pether Wiklander
Top achievements
Rank 2
answered on 28 Oct 2008, 09:56 AM
As I posted before... GridDropDownColumnEditor doesn't have a DropDownListControl property. So your example is no good.

Still... are there any code examples of how to use a metod to fill the DropDownList and to use the RadGrid's data source to determine which element in the DropDownList that should be selected?

// Pether
0
Sebastian
Telerik team
answered on 31 Oct 2008, 08:44 AM
Hello Pether,

You need to use GridDropDownListColumnEditor instead of GridDropDownColumnEditor as only object of the first class has DropDownListControl property. We will update the help topic accordingly - thank you for drawing our attention to this detail. I updated your Telerik points for the feedback.

In order to select the item in the dropdown editor which corresponds to the value from the column cell in non-editable row mode, consider using DataBinder.Eval(e.Item.DataItem, "<MyDropDownColumnName>").ToString() expression inside the ItemDataBound handler of the grid.

Kind regards,
Stephen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Pether Wiklander
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Pether Wiklander
Top achievements
Rank 2
Sebastian
Telerik team
Shinu
Top achievements
Rank 2
Share this question
or