I have a radcombobox with checkboxes turned on. I wrote a jQuery script to add a click event to all of them. What I need to move on to the next step is a way to get the combobox in which that item/checkbox resides. Something like this:
$(."comboBoxTag.find(":checkbox").click(
function(){
var cboObject = $(this).???
});
this way I can do things like access the telerik api methods like cboObject.get_items();
I have the control tagged with a CSS class called "AssigneeTag", but doing a .closest(".AssigneeTag") isn't returning anything...
any ideas?
UPDATE: As requested:
<h1>Tickets Assigned to Me</h1>
<rad:RadListView runat="server" ID="lsvTickets">
<ItemTemplate>
<div id="divContainer" class="divContainer">
<div id="divTicketHeader" class="divTicketHeader">
<asp:Table runat="server" ID="tblTicketHead" Width="100%" CellSpacing="0" CellPadding="5" HorizontalAlign="Center">
<asp:TableRow HorizontalAlign="Left">
<asp:TableCell Width="25%">
<asp:Label ID="lblSubject" runat="server" Text='<%#Eval("Subject") %>' Font-Bold="true" />
</asp:TableCell><asp:TableCell Width="25%">
<asp:Label ID="lblStatus" runat="server" Text='<%#Eval("Status.Key") %>' />
</asp:TableCell><asp:TableCell Width="25%">
<asp:Label ID="lblReportedBy" runat="server" Text='<%#Eval("CreatedBy.Key") %>' />
</asp:TableCell><asp:TableCell Width="25%">
<asp:Label ID="lblDateOpened" runat="server" Text='<%#Eval("DateOpened") %>' />
</asp:TableCell></asp:TableRow></asp:Table></div><div id="divTicketBody" class="divComments">
<rad:RadListView runat="server" ID="lsvActions" DataSource='<%#Eval("Comments") %>' ItemPlaceholderID="ph1" ClientIDMode="Static">
<ItemTemplate>
<div id="divComment" class="divComment">
<asp:Table runat="server" ID="tblComment" CellPadding="5">
<asp:TableRow>
<asp:TableCell Width="15%" HorizontalAlign="Center">
<rad:RadBinaryImage runat="server" ID="imgCommenter" Width="50" Height="50" /><br />
<asp:Label ID="Label5" runat="server" Text="[action author]" /><br />
<asp:Label ID="Label6" runat="server" Text='<%#Eval("CreateDate", "{0:MMM d, yyy hh:mm}") %>'
CssClass="commenterText"/><br />
</asp:TableCell><asp:TableCell>
<asp:Label ID="Label7" runat="server" Text='<%#Eval("CommentText") %>' />
</asp:TableCell></asp:TableRow></asp:Table></div></ItemTemplate><LayoutTemplate>
<center>
<div id="divAddComment" style="width: 500px;" class="CommentTopLevel">
<div id="divCommentControls" style="margin: 8px 0px 8px 0px;">
<asp:HiddenField runat="server" ID="hfID" Value='<%#Eval("TicketID") %>' />
<rad:RadComboBox runat="server" ID="cboStatus" DataSource='<%#GetStatuses() %>' DataTextField="Status" DataValueField="Support_StatusID" CssClass="StatusTag" EnableViewState="true" />
<rad:RadCombobox runat="server" ID="cboAssignTo" DataSource='<%#GetAssignees() %>' DataTextField="Name" DataValueField="Guid" ItemDataBound="Assignees_Bound" CssClass="AssigneeTag" CheckBoxes="true" OnItemChecked="AssigneeChecked" />
<rad:RadTextBox runat="server" ID="txtComment" TextMode="MultiLine" Width="500" Height="100" CssClass="CommentBox" /><br />
</div>
<div style="height: 35px;">
<div style="float:right; margin: 3px 0 0 0; ">
<rad:RadButton runat="server" CssClass="submitTag" ID="btnSubmit" Text="Submit" /><br />
<div class="SubmitStatus"></div>
</div>
</div>
</div>
</center>
<asp:PlaceHolder ID="ph1" runat="server" />
</LayoutTemplate>
</rad:RadListView>
</div>
</div>
</ItemTemplate>
</rad:RadListView>
This is a listview with another listview nested in the itemtemplate. in the itemtemplate of the inner list resides the controls. The combobox im referring to is named cboAssignTo. It is a Telerik combobox, so it does not work like a traditionial DropDown menu, which I think is what is really complicating this on top of the fact that the comboboxes are dynamically generated. I was able to do things like $(this).closest(".rcbTag") to get the values of the other combobox called cboStatus, but this other combobox involves a bit more as it has checkboxes.
EDIT:
Here is a watered down easier to read version of what stage I'm at. This is the HTML generated by a single instance of this combobox:
<div id="lsvTest" class="RadComboBox RadComboBox_Default RcbTag" style="width:160px;">
<table summary="combobox" style="border-width:0;border-collapse:collapse;table-layout:fixed;width:100%">
<tr class="rcbReadOnly">
<td style="margin-top:-1px;margin-bottom:-1px;width:100%;" class="rcbInputCell rcbInputCellLeft">
<input name="lsvTest" type="text" class="rcbInput" id="lsvTest_Input" value="" style="display: block;" readonly="readonly" />
</td>
<td style="margin-top:-1px;margin-bottom:-1px;" class="rcbArrowCell rcbArrowCellRight">
<a id="lsvTest_Arrow" style="overflow: hidden;display: block;position: relative;outline: none;">select</a>
</td>
</tr>
</table>
<!-- 2012.1.215.40 -->
<div class="rcbSlide" style="z-index:6000;">
<div id="lsvTest_DropDown" class="RadComboBoxDropDown RadComboBoxDropDown_Default " style="float:left;display:none;">
<div class="rcbScroll rcbWidth" style="width:100%;">
<ul class="rcbList" style="list-style:none;margin:0;padding:0;zoom:1;">
<li class="rcbItem "><input type="checkbox" class="rcbCheckBox" />One</li>
<li class="rcbItem "><input type="checkbox" class="rcbCheckBox" />Two</li>
<li class="rcbItem "><input type="checkbox" class="rcbCheckBox" />Three</li>
</ul>
</div>
</div>
</div>
<input id="lsvTest_ClientState" name="lsvTest_ClientState" type="hidden" />
</div>
Just looking at this, I feel like clicking a checkbox and then using $(this).closest(".RcbTag") should traverse all the way to the top and grab the outer div, but it is not.
我使用jQuery parent()调用解决了类似的问题,您尝试过吗?
As with the other question, I think your life will be easier if you stick with the Telerik-sanctioned methods. Here is how you could do it using them:
<script language="javascript" type="text/javascript">
function OnClientItemChecked(sender, eventArgs) {
var item = eventArgs.get_item();
var combo = item.get_comboBox(); // Now you have a reference to the parent ComboBox
}
</script>
And the RadComboBox itself:
<telerik:RadComboBox ID="RadComboBox1" runat="server"
OnClientItemChecked="OnClientItemChecked" CheckBoxes="true">
</telerik:RadComboBox>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.