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

ComboBox in Repeater - javascript

3 Answers 88 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
jgig
Top achievements
Rank 1
jgig asked on 18 Nov 2008, 04:45 PM
I have 2 ComboBoxes in a repeater and I need to set the javascript value in the second row with the reverse of the first row.

Repeater-
Row 1 - ComboBox_BEGIN, ComboBox_END, ...other controls
Row 2 - ComboBox_BEGIN, ComboBox_END, ...other controls

after the user selects a ComboBox_BEGIN value in row 1 I want to via javascript set the value in row 2 ComboBox_END. all the samples Ive seen that are showing this arent using a repeater so its a bit unclear. I was trying to set this up in the PreRender of the repeater, adding an onblur of the Row 1 - ComboBox_BEGIN. I have that code ready but when I add it, it adds it to the outer div the control renders and not the child textbox.

Can someone send me a link or a code sample that shows some similar functionality so I can understand how to do this. (if it matters these ComboBoxes are Loaded on Demand also)

3 Answers, 1 is accepted

Sort by
0
jgig
Top achievements
Rank 1
answered on 18 Nov 2008, 10:20 PM
So basically this is what Im trying to do on PreRender:
 

foreach

 

(RepeaterItem item in rpt.Items)

 

 

{

 

 

RadComboBox rcbBegin = (RadComboBox)item.FindControl("Beginrcb");

rcbBegin.Attributes.Add(

"onblur", string.Format("somefunction('{0}', '{1}');", rcbBegin.ClientID, rcbAnother.ClientID));

//the ONBLUR never fires because it is placed on the <div tag that holds all of the RadComboBox once Rendered

}

I can do the rest if I can just pass the 2 different Client IDs im looking for

 

0
Accepted
Veselin Vasilev
Telerik team
answered on 21 Nov 2008, 12:35 PM
Hello jgig,

You can do the following:

1. Add a custom attribute - NextComboID to your comboboxes:

foreach (RepeaterItem item in rpt.Items) 
  RadComboBox rcbBegin = (RadComboBox)item.FindControl("Beginrcb"); 
  rcbBegin.Attributes["NextComboID"] = rcbAnother.ClientID; 

2. Subscribe to the OnClientBlur event and focus to the next combobox:

function onBlurHandler(sender, eventArgs) 
    var nextComboID = sender.get_attributes().getAttribute("NextComboID"); 
    var nextCombo = $find(nextComboID); 
    if (nextCombo) 
    { 
        var input = nextCombo.get_inputDomElement(); 
        input.focus(); 
    }         

I hope this helps.

Sincerely yours,
Veselin Vasilev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
jgig
Top achievements
Rank 1
answered on 21 Nov 2008, 02:41 PM
thanks for your reply. This is exactly what I was looking for
Tags
ComboBox
Asked by
jgig
Top achievements
Rank 1
Answers by
jgig
Top achievements
Rank 1
Veselin Vasilev
Telerik team
Share this question
or