DataTables ( http://www.datatables.net/ ) 및 Bootstrap datepicker를 사용하고 있습니다. 내 JSFiddle : http://jsfiddle.net/wg3b6y7m/ 및 날짜 범위 필터에 대한 코드 는 다음과 같습니다 .
function (oSettings, aData, iDataIndex) {
if ($('#min').val() == '' && $('#max').val() == '') {
return true;
}
if ($('#min').val() != '' || $('#max').val() != '') {
var iMin_temp = $('#min').val();
if (iMin_temp == '') {
iMin_temp = '01/01/2000';
}
var iMax_temp = $('#max').val();
if (iMax_temp == '') {
iMax_temp = '31/12/2999'
}
var arr_min = iMin_temp.split("/");
var arr_max = iMax_temp.split("/");
// aData[column with dates]
var arr_date = aData[1].split("/");
var iMin = new Date(arr_min[2], arr_min[0], arr_min[1], 0, 0, 0, 0)
var iMax = new Date(arr_max[2], arr_max[0], arr_max[1], 0, 0, 0, 0)
var iDate = new Date(arr_date[2], arr_date[0], arr_date[1], 0, 0, 0, 0)
if (iMin == "" && iMax == "") {
return true;
} else if (iMin == "" && iDate < iMax) {
return true;
} else if (iMin <= iDate && "" == iMax) {
return true;
} else if (iMin <= iDate && iDate <= iMax) {
return true;
}
return false;
}
});
datepicker 범위 필터에 문제가 있습니다. 01/01/2015에서 01/28/2015까지 범위를 선택하면 행이 잘 필터링됩니다 ( "Date Created"두 번째 열 필터링). "종료일"을 2015 년 1 월 29 일로 변경하자마자 2 월 날짜가있는 첫 번째 행이 나타납니다. 내 범위가 여전히 1 월인 데 2 월 날짜를 포함하는 이유는 무엇입니까?
나는 무엇이 잘못되었는지 알아 냈다. 다음은 업데이트 된 코드 스 니펫입니다.
var iMin = new Date(arr_min[2], parseInt(arr_min[0])-1, arr_min[1], 0, 0, 0, 0)
var iMax = new Date(arr_max[2], parseInt(arr_max[0])-1, arr_max[1], 0, 0, 0, 0)
var iDate = new Date(arr_date[2], parseInt(arr_date[0])-1, arr_date[1], 0, 0, 0, 0)
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다