Hi All,
I have added a custom column or cell containing DrodownList -its appearing correctly in view mode.
Now I have below points :
1. On which event of the GridView I can bind the dropdownList.
2. When I select any value (Currently have added some static value in the DropdownList). Once I scroll the grid , the state changes to original state.
3. Some time I noticed that the value i selected for let say row one, the same value is being selected for the the row which is not displayed. after scrolling we can see the same. and the value of 1st row got removed.
4. My requirement is -
- I need to give a data source to the Drodownlist.
- Need to get a value selected on some condition
- If I scroll the value should not change.
Attaching my code of custom cell
class
CustomDropCell : GridDataCellElement
{
private
string
conString {
get
;
set
; }
public
CustomDropCell(GridViewColumn column, GridRowElement row):
base
(column, row)
{
//conString = con;
}
private
StackLayoutPanel panel;
private
RadDropDownListElement radDropDownList;
protected
override
void
CreateChildElements()
{
base
.CreateChildElements();
this
.panel =
new
StackLayoutPanel();
this
.panel.Margin =
new
System.Windows.Forms.Padding(5);
this
.panel.Orientation = System.Windows.Forms.Orientation.Vertical;
this
.radDropDownList =
new
RadDropDownListElement
{
DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDownList
};
this
.radDropDownList.Items.Add(
"Santosh"
);
this
.radDropDownList.Items.Add(
"Jha"
);
this
.radDropDownList.Items.Add(
"Mr"
);
this
.radDropDownList.Items.Add(
"Kumar"
);
this
.Children.Add(radDropDownList);
}
protected
override
void
SetContentCore(
object
value)
{
GridViewGroupRowInfo row =
this
.RowInfo
as
GridViewGroupRowInfo;
object
cellValue = value;
if
(cellValue
is
DBNull || cellValue ==
null
)
cellValue =
"Mr"
;
this
.radDropDownList.SelectedValue = cellValue;
}
protected
override
Type ThemeEffectiveType
{
get
{
return
typeof
(GridDataCellElement);
}
}
public
override
bool
IsCompatible(GridViewColumn data,
object
context)
{
return
base
.IsCompatible(data, context);
// return data is CustomDropCellColumn && context is GridDataRowElement;
}
}
public
class
CustomDropCellColumn : GridViewDataColumn
{
//private string conString { get; set; }
public
CustomDropCellColumn(
string
fieldName) :
base
(fieldName)
{
//conString = connectionString;
}
public
override
Type GetCellType(GridViewRowInfo row)
{
if
(row
is
GridViewDataRowInfo)
{
return
typeof
(CustomDropCell);
}
return
base
.GetCellType(row);
}
}
Adding the column in Grid in Form Constructor.
CustomDropCellColumn customColumn =
new
CustomDropCellColumn(
"Destination Table"
);
customColumn.MaxWidth = 170;
this
.radGridViewTable.Columns.Add(customColumn);
this
.radGridViewTable.Columns[
"Destination Table"
].MinWidth = 165;