简体   繁体   English

下拉列表在响应式jquery数据表中不起作用

[英]Dropdown not work in responsive jquery datatable

I am using responsive jquery datatable. 我正在使用响应式jQuery数据表。

Check this link http://jsfiddle.net/82v4p7cL/1/ 检查此链接http://jsfiddle.net/82v4p7cL/1/

<div id="tblSkippedItems_wrapper" class="dataTables_wrapper form-inline dt-bootstrap no-footer"><div class="row"><div class="col-sm-12"><table id="tblSkippedItems" class="table table-striped table-bordered nowrap dataTable no-footer dtr-inline collapsed" cellspacing="0" width="100%" role="grid" aria-describedby="tblSkippedItems_info" style="width: 100%;">
                                <thead>
                                    <tr role="row"><th class="sorting_asc" tabindex="0" aria-controls="tblSkippedItems" rowspan="1" colspan="1" style="width: 159px;" aria-label="Itemnumber: activate to sort column descending" aria-sort="ascending">Itemnumber</th><th class="sorting" tabindex="0" aria-controls="tblSkippedItems" rowspan="1" colspan="1" style="width: 0px; display: none;" aria-label="Location : activate to sort column ascending"></th></tr>
                                </thead>
                            <tbody>
   <tr role="row" class="odd parent">
      <td class="sorting_1" tabindex="0" style="">02-273-BU</td>
      <td style="display: none;"> 
         <select id="ddlTest" style="width: 300px">
      </td>
        </tr>
   <tr class="child">
      <td class="child" colspan="2">
         <ul data-dtr-index="1">
            <li data-dtr-index="2" data-dt-row="1" data-dt-column="2"><span class="dtr-title">Location <small>(Picking)</small></span> <span class="dtr-data"><span class="ClsLocName">N/A </span>  <select id="ddlTest" style="width: 300px"></select></span></li>
         </ul>
      </td>
   </tr>
</tbody>
</table></div></div>
</div>

I have dropdown column in jquery datatable. 我在jquery数据表中有下拉列。

In responsive mode, new tr is created with class "child". 在响应模式下,将使用类“ child”创建新的tr。 And old tr is hide. 老tr是皮。

Both tr contain dropdown with same id. 两个tr包含具有相同ID的下拉列表。 When I try to add options to dropdown using jquery, no effect on dropdown. 当我尝试使用jquery向下拉列表添加选项时,对下拉列表没有任何影响。

 var ddl = $('#DdlTest');
ddl.append($("<option></option>").val('0').html('Selectvalue'));

The id attribute specifies a unique id for an HTML element (the value must be unique within the HTML document). id属性指定HTML元素的唯一ID(该值在HTML文档中必须是唯一的)。

Try using a different id in your dropdown, you can only have 1 element with a specific id in every page, the script is working but it will append the options on the first element with that specific id. 尝试在下拉菜单中使用其他ID,每个页面中只能有1个具有特定ID的元素,脚本正在运行,但是它将在具有该特定ID的第一个元素上附加选项。

There are several issues with your html and jquery select. 您的html和jquery选择存在几个问题。 first you didn't close the select tag try closing it and second ddlTest is not equal to DdlTest . 首先,您没有关闭select标记,请尝试将其关闭,第二个ddlTest不等于DdlTest you need to fix these issues then append your option. 您需要解决这些问题,然后附加您的选项。

 <select id="ddlTest" style="width: 300px"></select>

JavaScript JavaScript的

var ddl = $('#ddlTest');
ddl.append($("<option value="0"></option>");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM