小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

javascript-通過選擇datepickers創(chuàng)建datatable標頭

 印度阿三17 2019-11-20

我試圖創(chuàng)建帶有動態(tài)列的dataTable以便從& to選擇日期選擇器.

列應在日期和toDate之間包含fromDate

JS代碼

$("#from").datepicker();
$("#to").datepicker(); 

var strTopHead='<th rowspan="2">Name</th><th rowspan="2">Code</th><th rowspan="2">code</th>';

$('#getBetween').on('click', function () {

    $('#trTopHead').empty();
     $('#trBottomHead').empty();
    var start = $("#from").datepicker("getDate"),
        end = $("#to").datepicker("getDate"),
        currentDate = new Date(start),
        between = []
    ;
    if(start!=null&&end!=null){
    while (currentDate <= end) {
        between.push(new Date(currentDate).toJSON().substring(0,10));
        currentDate.setDate(currentDate.getDate()   1);
    }

  //  $('#results').html(between.join('<br> '));
    for(var i=0;i<between.length;i  ){
        strTopHead=strTopHead '<th colspan="3">' between[i] '</th>';

    $('#trBottomHead').append('<th>C</th><th>D</th>               <th>E</th>');
        $('table>tbody').append('<tr><td>Tiger Nixon</td>                <td>System Architect</td>                <td>$320,800</td>                <td>Edinburgh</td>                <td>5421</td>               <td>t.nixon@datatables.net</td></tr>');
    }
            $('#trTopHead').append(strTopHead);

        $('#example').dataTable({
        "scrollY":        "200px",
        "scrollCollapse": true
        });
    }
});

這里僅將單個日期顯示為列

I tried like this

解決方法:

我已經(jīng)對您的代碼做了一些修改

var date= new Date();//changes
$("#from").datepicker();
$("#to").datepicker();

$("#from").val($.datepicker.formatDate("mm/dd/yy",date));//changes
$("#to").val($.datepicker.formatDate("mm/dd/yy",date));//changes


$('#getBetween').on('click', function () {
    var strTopHead='';
    $('#trTopHead').empty();
     $('#trBottomHead').empty();
   strTopHead=strTopHead  '<th rowspan="2">Name</th><th rowspan="2">Code</th><th rowspan="2">code</th>';
    var start = $("#from").datepicker("getDate"),
        end = $("#to").datepicker("getDate"),
        currentDate = new Date(start),
        between = []
    ;
    if(start!=null&&end!=null){
    while (currentDate <= end) {
        currentDate.setDate(currentDate.getDate()   1);//changes
        between.push(new Date(currentDate).toJSON().substring(0,10));//changes

    }
    var strTopHeadDates='';
  //  $('#results').html(between.join('<br> '));
    for(var i=0;i<between.length;i  ){
        strTopHeadDates=strTopHeadDates '<th colspan="3">' between[i] '</th>';

    $('#trBottomHead').append('<th>C</th><th>D</th>               <th>E</th>');
        $('table>tbody').append('<tr><td>Tiger Nixon</td>                <td>System Architect</td>                <td>$320,800</td>                <td>Edinburgh</td>                <td>5421</td>               <td>t.nixon@datatables.net</td></tr>');
    }
        strTopHead=strTopHead strTopHeadDates;
            $('#trTopHead').append(strTopHead);

     $('#example').dataTable();
        console.log($("#from").val());
    }
});

try this code

來源:https://www./content-1-569001.html

    本站是提供個人知識管理的網(wǎng)絡存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約