how RadComboBox in table header change all RadComboBoxs in asp.net Repeater

4 posts, 1 answers
  1. AHMED
    AHMED avatar
    5 posts
    Member since:
    Nov 2014

    Posted 27 Mar Link to this post

    Hello, 

    please I need your help in client side code ,

    I need  javascript code that explain how can RadComboBox in header affects on all RadComboBoxs in asp repeater rows,

    how can set same value and same text .

     

    thanks

  2. AHMED
    AHMED avatar
    5 posts
    Member since:
    Nov 2014

    Posted 31 Mar Link to this post

    Please I need your help 

     

  3. Answer
    Peter Milchev
    Admin
    Peter Milchev avatar
    586 posts

    Posted 01 Apr Link to this post

    Hello Ahmed,

    Please provide more details on the exact Repeater and ComboBox configuration and provide more specific examples of what exactly should happen.

    One possible option to access all ComboBoxes in the Repeater would be if you add a custom CSS class to the CssClass property of the ComboBoxes you would like to modify and when needed to use JavaScript to access all combo boxes. Then, you can iterate them, access the client-side object and use their API.

    Here is a very simple example that synchronizes the selected items across all ComboBoxes in the Repeater that have the "myclass" set to the CssClass property: 

    <script>
        window.isProgrammaticSelection = false;
        function OnClientSelectedIndexChanged(sender, args) {
            if (!window.isProgrammaticSelection) {
                window.isProgrammaticSelection = true;
                var allComboBoxes = $telerik.$(".myclass");
                var value = args.get_item().get_value();
                for (var i = 0; i < allComboBoxes.length; i++) {
                    var combo = allComboBoxes[i].control;
     
                    var item = combo.findItemByValue(value);
                    item.select();
                }
                window.isProgrammaticSelection = false;
            }
        }
     
    </script>

    <asp:Repeater ID="Repeater1" OnItemDataBound="Repeater1_ItemDataBound" runat="server">
        <ItemTemplate>
            <telerik:RadComboBox ID="RadComboBox1" CssClass="myclass" runat="server" RenderMode="Lightweight"
                OnClientSelectedIndexChanged="OnClientSelectedIndexChanged">
                <Items>
                    <telerik:RadComboBoxItem Text="Item 1" Value="1" />
                    <telerik:RadComboBoxItem Text="Item 2" Value="2" />
                    <telerik:RadComboBoxItem Text="Item 3" Value="3" />
                    <telerik:RadComboBoxItem Text="Item 4" Value="4" />
                </Items>
            </telerik:RadComboBox>
            <br />
        </ItemTemplate>
    </asp:Repeater>

    protected void Page_Load(object sender, EventArgs e)
    {
        Repeater1.DataSource = Enumerable.Range(1, 10).Select(x => "Item " + x.ToString());
        Repeater1.DataBind();
    }
     
    protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        var combo = e.Item.FindControl("RadComboBox1") as RadComboBox;
        
    }

    Regards,
    Peter Milchev
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.

  4. AHMED
    AHMED avatar
    5 posts
    Member since:
    Nov 2014

    Posted 01 Apr in reply to Peter Milchev Link to this post

    Thank you very much, you solved my problem :)
Back to Top