[Completely new with Telerik]
Hi
I have a Category column in Employee Table as of type GridViewComboBoxColumn and i have assigned a datasource to it.
The values of this column can be "Male" or "Female". The datasouce contains these two values.
While adding new record I want to pick up 1st available value in datasource as default selected.
How can i do this?
Regards
Raghu.
5 Answers, 1 is accepted
0
Hello Lee,
Thank you for the question. Currently RadGridView does not support setting default values for combo box column. However, you can implement the desired functionality by creating custom editor. Please, consider the following code:
Do not hesitate to contact me again if you have any other questions.
Kind regards,
Martin Vasilev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Thank you for the question. Currently RadGridView does not support setting default values for combo box column. However, you can implement the desired functionality by creating custom editor. Please, consider the following code:
void
radGridView1_EditorRequired(
object
sender, EditorRequiredEventArgs e)
{
if
(e.EditorType ==
typeof
(RadComboBoxEditor))
{
e.EditorType =
typeof
(CustomComboEditor);
}
}
class
CustomComboEditor : RadComboBoxEditor
{
public
override
void
BeginEdit()
{
base
.BeginEdit();
RadComboBoxEditorElement editorElement =
this
.EditorElement
as
RadComboBoxEditorElement;
if
(editorElement.SelectedIndex == -1)
{
editorElement.SelectedIndex = 0;
}
}
}
Do not hesitate to contact me again if you have any other questions.
Kind regards,
Martin Vasilev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Bob
Top achievements
Rank 2
answered on 18 Jun 2012, 09:06 PM
I was curious to know if there has been an update to the control in order to assign a default or "first" item in the bound gridviewComboBoxColumn?
Thanks
Bob
Thanks
Bob
0
Bob
Top achievements
Rank 2
answered on 18 Jun 2012, 09:07 PM
I was curious to know if there has been an update to the control in order to assign a default or "first" item in the bound gridviewComboBoxColumn?
Thanks
Bob
Thanks
Bob
0
Hello Bob,
Thank you for writing.
In the latest version, the combo column uses RadDropDownList editor and selecting a default item for it will not require overriding the whole editor. You can just use the CellEditorInitialized event handler:
I hope this helps.
Stefan
the Telerik team
Thank you for writing.
In the latest version, the combo column uses RadDropDownList editor and selecting a default item for it will not require overriding the whole editor. You can just use the CellEditorInitialized event handler:
void
radGridView1_CellEditorInitialized(
object
sender, GridViewCellEventArgs e)
{
RadDropDownListEditor editor = e.ActiveEditor
as
RadDropDownListEditor;
if
(editor !=
null
)
{
RadDropDownListEditorElement element = editor.EditorElement
as
RadDropDownListEditorElement;
element.SelectedIndex = 1;
}
}
I hope this helps.
All the best,
Stefan
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
0
Bob
Top achievements
Rank 2
answered on 21 Jun 2012, 02:33 PM
Just what I was looking for - thanks!