我有一个包含divisionName
的下拉列表,但我希望divisionID
在下拉列表中。有人知道吗?
// dropdownList
function divisionDropDownEditor(container, options) {
$('<input required name="' + options.field + '"/>')
.appendTo(container)
.kendoDropDownList({
autoBind: false,
dataTextField: "divisionName",
dataValueField: "divisionID",
dataSource: {
type: "POST",
transport: {
read: "http://vx-dev.ehors.com:8480/najwa/getDivisionName.php"
}
}
});
}
// getDivisionName.php file
<?php
##############################################################
#### Fetch data from database and display into JSON format ###
##############################################################
$getcheckbox = (isset($_POST['c1']) ? $_POST['c1'] : "all"); // by default select *
$propertyID="1";
include("../EHORS.pdo.php");
$ehorsObj = new EHORS();
$ehorsObj->EHORS_CONNECT($propertyID);
$sql = "SELECT divisionID, divisionName FROM tblAdmDivision";
/* $sql = "SELECT tblAdmDepartment.divisionID, tblAdmDivision.divisionName
FROM tblAdmDepartment
INNER JOIN tblAdmDivision
ON tblAdmDepartment.divisionName = tblAdmDivision.ivisionID";*/
if ($getcheckbox == "true") {
$sql .= " WHERE active = 'y' ";
}
//$sql .= " ORDER BY 2 ASC " ; // ordr by segmentName
$array = array();
// /* PDO */
$GetResult = $ehorsObj->FetchData($sql, $ehorsObj->DEFAULT_PDO_CONNECTIONS);
while ($row = $GetResult->fetch()){
$array[] = $row;
}
header("Content-type: application/json");
$result = json_encode($array);
echo $result;
?>