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

Combobox for grid page items number selector

3 Answers 112 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 17 Dec 2010, 11:16 PM
Hello,

I am using a RadComboBox as a selector for the number of items in a grid. What I have been using this far is the following JavaScript at the page level:

<

 

script type="text/javascript">

 

 

function ddlPageSize_SelectedIndexChanged(sender, args) {

 

 

var obj = $find("<%= LineItemsGrid.ClientID %>")

 

tableView = obj.get_masterTableView();

tableView.set_pageSize(sender.get_value());

}

</

 

script>

 

This has been working great, however, now we have a page requiring multiple grids. We have been trying for a while to get a reference of the grid's MasterTableView by inspecting both sender and args and navegating the hierarchy. Can you provide some insight as to how this can be achieved?

Thanks,

David


3 Answers, 1 is accepted

Sort by
0
David
Top achievements
Rank 1
answered on 13 Sep 2011, 02:28 PM
Hello,

On a related note, same grid, I am in the need of referencing RadComboboxes and call the method that is also called OnClientSelectedIndexChanged.

More specifically, the JavaScript method that is called has an argument passed into it, which is a Telerik object. The method does things to it, such as enable/disable relative controls, etc... I now need to iterate through all the comboboxes on the grid and call this method on them, but I can't seem to reference them correctly. Here is what I have tried,  which is throwing null exceptions on a call to get_id() from within the method:

                           <ItemTemplate>
                                <span class="validatable">
                                    <telerik:RadComboBox  ID="ddlHostType" 
                                                          runat="server" 
                                                          DataTextField="Text" 
                                                          DataValueField="Value" 
                                                          AutoPostBack="false"
                                                          CausesValidation="false"
                                                          Width="85px"
                                                          OnClientSelectedIndexChanged="setAvailableHostValues"
                                                          
                                    />
                                    <asp:RequiredFieldValidator ID="vldHostType" 
                                                                runat="server" 
                                                                ErrorMessage="Please select a Host ID Type" 
                                                                ControlToValidate="ddlHostType" 
                                                                EnableClientScript="false"
                                                                CssClass="validationErrorMessages"
                                    />
                                </span>
                            </ItemTemplate>                           <ItemTemplate>
                                <span class="validatable">
                                    <telerik:RadComboBox  ID="ddlHostType" 
                                                          runat="server" 
                                                          DataTextField="Text" 
                                                          DataValueField="Value" 
                                                          AutoPostBack="false"
                                                          CausesValidation="false"
                                                          Width="85px"
                                                          OnClientSelectedIndexChanged="setAvailableHostValues"
                                                          
                                    />
                                    <asp:RequiredFieldValidator ID="vldHostType" 
                                                                runat="server" 
                                                                ErrorMessage="Please select a Host ID Type" 
                                                                ControlToValidate="ddlHostType" 
                                                                EnableClientScript="false"
                                                                CssClass="validationErrorMessages"
                                    />
                                </span>
                            </ItemTemplate>

And the script I am calling....


    $(".rcbReadOnly input[type=text]").each(function() { // this is where I think I am referencing incorrectly...
        if (this.id.indexOf("ddlHostType") > -1) {
            var myId = $(this).parents("div").attr("id");

            var cbo = $find(myId);
            if (cbo != null) {
                setAvailableHostValues($find(myId));
            }
        }
    });
0
Dimitar Terziev
Telerik team
answered on 19 Sep 2011, 09:34 AM
Hi David,

Try to get the elements which have the "RadComboBox" or "RadComboBox_SkinName" class and then obtain their id attribute. The div element wrapping the RadComboBox has this id attribute and not the input element which you are getting now.

Greetings,
Dimitar Terziev
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal
0
David
Top achievements
Rank 1
answered on 19 Sep 2011, 01:55 PM
Yep. I eventually tried that and it worked. Thanks!
Tags
ComboBox
Asked by
David
Top achievements
Rank 1
Answers by
David
Top achievements
Rank 1
Dimitar Terziev
Telerik team
Share this question
or