doushuangai9733 2018-12-18 18:53
浏览 49

在DataTables中迭代具有类名的单元格

I have a datatable named results. 1 column has select dropdowns which all have a class of contracts. When the table is populated, I need to have all those select boxes be checked to assure they have a value greater than 0. I need this to happen on ALL rows and not just the visible ones.

The following works, but only on the visible page:

jQuery(".contract").each(function() {
    id = jQuery(this).attr('id');
    val = jQuery("#"+id).val()
console.log("Preparing to check "+id+" with a value of "+val+"
");
    if(val==0) {
        validation(false, 'Required', 'div_'+id, 'input_'+id, false);
    } else {
        validation(true, '', 'div_'+id, 'input_'+id, false);
    }
})

Any insight on how to get the remainder of the pages to also use this block would be appreciated. I am using the FREE version of DataTables.

UPDATE:

ok, I can get to the cells using the following:

table.column(5).nodes().to$().each(function(index) {
//  jQuery(".contract").each(function() {
    var cell = table.cell(this).data();
    id = jQuery(cell).attr('id');
})

Within each cell is a select box with the following HTML:

<div id="div_player_20">
     <div id="input_player_20">
        <select id="player_20">
            <option value="0" disabled="disabled">-- None --</option>
            <option value="2" disabled="disabled">Lifetime</option>
            <option value="1" selected="selected" disabled="disabled">7 Year</option>
            <option value="3" disabled="disabled">6 Year</option>
            <option value="4" disabled="disabled">5 Year</option>
            <option value="5" disabled="disabled">4 Year</option>
            <option value="6" disabled="disabled">3 Year</option>
            <option value="7" disabled="disabled">2 Year</option>
            <option value="8" disabled="disabled">1 Year</option>
            <option value="9" disabled="disabled">Minor League</option>
        </select>
    </div>
</div>

I need to be able to get the selected value from each dropdown (including those that are off the screen)

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥30 这是哪个作者做的宝宝起名网站
    • ¥60 版本过低apk如何修改可以兼容新的安卓系统
    • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
    • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
    • ¥50 有数据,怎么用matlab求全要素生产率
    • ¥15 TI的insta-spin例程
    • ¥15 完成下列问题完成下列问题
    • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
    • ¥15 YoloV5 第三方库的版本对照问题
    • ¥15 请完成下列相关问题!