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

Passing values

6 Answers 142 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
nek
Top achievements
Rank 1
nek asked on 03 Nov 2008, 07:00 PM

Hello,

I have textbox and RadComboBox (it is populated with load on demand method)
on user control edit form inside radgrid rows.
When I select RadComboBox how can I pass value to textbox ?
Thanks in advanced!

Regards

6 Answers, 1 is accepted

Sort by
0
paul
Top achievements
Rank 2
answered on 03 Nov 2008, 10:39 PM
I'm not sure I understand what problem you are having.

It would be helpful if you could post a short example of what you are trying to do.
0
nek
Top achievements
Rank 1
answered on 04 Nov 2008, 09:29 AM

I have Telerik grid on form and when I edit or insert new data I use custom edit form inside grid, like in this example(http://demos.telerik.com/aspnet/prometheus/Grid/Examples/DataEditing/UserControlEditForm/DefaultCS.aspx).
Here is the code from custom edit form(ascx) and it is openinig inside grid when I edit data.

        <td class="style3" align="left">
  <asp:TextBox id="txtProduct" runat="server"
      Text='<%# DataBinder.Eval( Container, "DataItem.Product"  ) %>'>
      </asp:textbox>
        </td>
        <td align="left">
            <telerik:RadComboBox ID="cboBuyer" runat="server" Width="100px" Height="200px" HighlightTemplatedItems="True"
                ItemRequestTimeout="500" AllowCustomText="True" NoWrap="true" ShowWhileLoading="true"
                DropDownWidth="180px" ShowToggleImage="True" ShowMoreResultsBox="true" EnableLoadOnDemand="True"
                MarkFirstMatch="True" OnItemsRequested="cboBuyer_ItemsRequested" EnableVirtualScrolling="true"
                Skin="WebBlue" EnableViewState="False" OnClientSelectedIndexChanged="HandleEndChanging">
                <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
            </telerik:RadComboBox>
      </td>

Here is the  function from main form (aspx), and it returns value from selected combobox(cboBuyer)

    <script type="text/javascript" language="javascript">
        function HandleEndChanging(sender, args) {

           var item = eventArgs.get_item();
           var inputElement = item.get_comboBox().get_inputDomElement();
           alert("Change to new item('" + sender.get_text() + "')");
        }
    </script>

How can I pass the selected value from combobox to txtProduct.
Probably it is simple solution but I don't know ho to solve it.

Thank you!

 

0
Veselin Vasilev
Telerik team
answered on 04 Nov 2008, 09:46 AM
Hi nek,

You can try the following:

<script type="text/javascript" language="javascript"
        function HandleEndChanging(sender, args) { 
 
           var item = args.get_item(); 
           var txt = $get("txtProduct"); 
           txt.value = sender.get_value(); 
        } 
    </script> 

I hope this helps.

All the best,
Veselin Vasilev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
nek
Top achievements
Rank 1
answered on 04 Nov 2008, 10:21 AM

Hi,

Unfortunately I am getting error

"Microsoft JScript runtime error: 'null' is null or not an object"
on line
"txt.value = sender.get_value();"

It seems to be problem with finding textbox "var txt = $get("txtProduct");"

Please help :)
Regards

0
Accepted
Veselin Vasilev
Telerik team
answered on 04 Nov 2008, 10:42 AM
Hello nek,

I apologize, here is the correct code:

<script type="text/javascript" language="javascript">    
        function HandleEndChanging(sender, args) {    
           var item = args.get_item();    
           var comboID = sender.get_id();  
           var txtID = comboID.replace("cboBuyer""txtProduct")  
           var txt = $get(txtID);    
           txt.value = sender.get_value();    
        }    
    </script>    
 


Best wishes,
Veselin Vasilev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
nek
Top achievements
Rank 1
answered on 04 Nov 2008, 11:04 AM
Hi,

Evertyhing works excellent!

Thank you and best regards
Tags
ComboBox
Asked by
nek
Top achievements
Rank 1
Answers by
paul
Top achievements
Rank 2
nek
Top achievements
Rank 1
Veselin Vasilev
Telerik team
Share this question
or