I have two related radcombobox on Popup editmode : cmbBo and cmbCoquan
ascx file
And in Cs file
The first cmbBo handler event
ascx file
<
script
type
=
"text/javascript"
>
function GetGridServerElement(serverID, tagName) {
if (!tagName)
tagName = "*";
var grid = $get("<%=RadGridCG.ClientID %>");
var elements = grid.getElementsByTagName(tagName);
for (var i = 0; i < elements.length; i++) {
var element = elements[i];
if (element.id.indexOf(serverID) >= 0)
return element;
}
}
function cmbBoClientSelectedIndexChangedHandler(sender, eventArgs) {
var cmbCoquan = GetGridServerElement("cmbCoquan");
cmbCoquan.add_itemsRequested(cmbCoquanItemsRequested);
cmbCoquan.requestItems(eventArgs.get_item().get_value(), false);
}
function cmbCoquanItemsRequested(sender, eventArgs) {
if (sender.get_items().get_count() > 0) {
// pre-select the first item
sender.findItemByText(sender.get_items().getItem(0).get_text()).select();
}
//detach the client items requested event as it not needed any more
sender.remove_itemsRequested(cmbCoquanItemsRequested);
}
And in Cs file
protected void RadGridCG_ItemCreated(object sender, GridItemEventArgs e)
{
if (e.Item is GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem editItem = (GridEditableItem)e.Item;
RadComboBox cmbBo = (RadComboBox)editItem.FindControl("cmbBo");
RadComboBox cmbCoQuan = (RadComboBox)editItem.FindControl("cmbCoQuan");
cmbBo.OnClientSelectedIndexChanged = "cmbBoClientSelectedIndexChangedHandler";
cmbCoQuan.ItemsRequested += new RadComboBoxItemsRequestedEventHandler(cmbCoQuan_ItemsRequested);
//cmbBo.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(cmbBo_SelectedIndexChanged);
}
}
protected void cmbCoQuan_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
{
GridEditableItem editItem = (sender as RadComboBox).NamingContainer as GridEditableItem;
RadComboBox cmbCoQuan = (RadComboBox)editItem.FindControl("cmbCoQuan");
cmbCoQuan.DataSource = LoadFilteredCoQuanManually(e.Value);
cmbCoQuan.DataBind();
}
cmbBoClientSelectedIndexChangedHandler
successed but i can't get the second radcombobox (cmbCoquan) , I use GetGridServerElement("cmbCoquan") method and this function not know this control as Radcombobox (error code on cmbCoquan.requestItems(eventArgs.get_item().get_value(), false)
)
My Question
: How to get Radcombobox on RadGrid popup use Javascript function? Or plz show me demo code for Related combobox on Radgrid popup ( Editmode ="PopUp")