Select DropDown Image第2集 我更新了DataTables php代码来搜索和收集添加或减少yadcf使用的json数据的数据。如果已经为过滤器选择了值,如何阻止yadcf更新选项值的列列表?当我重新选择过滤器时,将删除所有先前的选项,如果有人选择了错误的选项,我不希望这样做。如果要阻止select更新,我会使用下面的代码。此外,重置按钮不是我想要使用的选项。
if ( strindex[w] === 3 && GBselBoxphp3 === '' ) {
var selectoptdata = data.yadcf_data_3;
select.empty().append('<option value=""/>');
$.each(selectoptdata, function (i, j) {
select.append( '<option value="'+j+'">'+j+'</option>' )
});
}
第1集 您从Allan Jardine获取填充列下拉列表的解决方案已经清除了一个障碍,因此我可以对我的DataTables实施服务器端处理,但是将下面提到的更改添加到ssp.class.php会影响累积过滤。在缩小选定记录时,累积过滤是一项非常有用的功能。知道如何纠正这个问题吗?
stackoverflow.com/questions/41507443/yadcf-datatables-server-side-populate-select-with-php
$data=SSP::simple( $_POST, $sql_details, $table, $primaryKey, $columns);
$db = SSP::sql_connect( $sql_details );
$stmt3 = $db->prepare( 'SELECT DISTINCT(value) FROM table' );
$stmt3->execute();
$data['yadcf_data_3'] = $stmt3->fetchAll(PDO::FETCH_COLUMN, 0);
$stmt5 = $db->prepare( 'SELECT DISTINCT(value2) FROM table' );
$stmt5->execute();
$data['yadcf_data_5'] = $stmt5->fetchAll(PDO::FETCH_COLUMN, 0);
$stmt6 = $db->prepare( 'SELECT DISTINCT(value3) FROM table' );
$stmt6->execute();
$data['yadcf_data_6'] = $stmt6->fetchAll(PDO::FETCH_COLUMN, 0);
echo json_encode($data);
这是我对第3列的php代码所做的。这也是从Datatables输入搜索框的值。
if( !empty($requestData['columns'][3]['search']['value']) ){
$strselBoxphp3 = $requestData['columns'][3]['search']['value'];
} else {
$strselBoxphp3 = "";
}
//Column 3 DropDown Data
$db=SSP::sql_connect( $sql_details );
if( !empty($strsrchBoxvaluephp) ) {
$sql = ' SELECT DISTINCT SVD_Description FROM SVD_Equipment WHERE';
$sql .= ' (SVDid LIKE "%'.$strsrchBoxvaluephp.'%"';
$sql .= ' OR Audit LIKE "%'.$strsrchBoxvaluephp.'%"';
$sql .= ' OR SVD_Description LIKE "%'.$strsrchBoxvaluephp.'%"';
$sql .= ' OR Manufacture LIKE "%'.$strsrchBoxvaluephp.'%"';
$sql .= ' OR Model LIKE "%'.$strsrchBoxvaluephp.'%"';
$sql .= ' OR VIN LIKE "%'.$strsrchBoxvaluephp.'%"';
$sql .= ' OR State LIKE "%'.$strsrchBoxvaluephp.'%"';
$sql .= ' OR License_Plate_Number LIKE "%'.$strsrchBoxvaluephp.'%"';
$sql .= ' OR License_Plate_Expiration_Date LIKE "%'.$strsrchBoxvaluephp.'%"';
$sql .= ' OR Last_Inspection_Date LIKE "%'.$strsrchBoxvaluephp.'%"';
$sql .= ' OR Primary_Tech LIKE "%'.$strsrchBoxvaluephp.'%"';
$sql .= ' OR Manager LIKE "%'.$strsrchBoxvaluephp.'%")';
} else {
$sql = 'SELECT DISTINCT SVD_Description FROM SVD_Equipment WHERE SVD_Description != ""';
}
if( !empty($strselBoxphp2) ) {
$sql .= ' AND Audit = "'.$strselBoxphp2.'"';
}
if( !empty($strselBoxphp4) ) {
$sql .= ' AND Manufacture = "'.$strselBoxphp4.'"';
}
if( !empty($strselBoxphp5) ) {
$sql .= ' AND Model = "'.$strselBoxphp5.'"';
}
if( !empty($strselBoxphp11) ) {
$sql .= ' AND Primary_Tech = "'.$strselBoxphp11.'"';
}
if( !empty($strselBoxphp12) ) {
$sql .= ' AND Manager = "'.$strselBoxphp12.'"';
}
$sql .= ' ORDER BY SVD_Description;';
$stmt3 = $db->prepare($sql);
$stmt3->execute();
$data['yadcf_data_3'] = $stmt3->fetchAll(PDO::FETCH_COLUMN, 0);