【发布时间】:2019-08-19 01:55:38
【问题描述】:
我尝试在下拉列表中选择数据,然后提交到剑道网格。但是,数据未能插入到网格中。有人有想法或解决方案吗?
HTML 提交按钮
<button class="k-button" id="btnSave" value="submit" style="float:right; padding: 5px 20px; border-radius: 4px;" >Submit</button>
JavaScript 按钮提交
//AJAX call for button
$("#btnSave").kendoButton();
var button = $("#btnSave").data("kendoButton");
button.bind("click", function(e) {
var test = $("#accountLedger").val()
$.ajax({
url: "../GroupManagement/get.php",
type: "POST",
data: {
method: "addGroup",
accountLedgerID: $("#accountLedgerID").val()
},
success: function () {
kendo.alert ('success');
JavaScript 下拉菜单
$("#accountLedger").kendoDropDownList({
dataTextField: "accountLedgerName",
dataValueField: "accountLedgerID",
optionLabel: "Choose account ledger",
dataSource: {
transport: {
read: {
url: "./getCoaGroup.php",
type: "POST",
data: function() {
return {
method: "getAccLedger",
}
}
},
},
},
//change: onChange(),
change: function(e){
console.log(this.value());
$('#grid').data('kendoGrid').dataSource.read();
homogeneous.read();
}
}).data('kendoDropDownList');
dropdownlist = $("#accountLedger").data("kendoDropDownList");
JavaScript 剑道网格
columns: [
columns: [
{ field: "active", title:" ", filterable:false,
template: "# if( data.active == 'y' ){# <span class='k-icon ehors-status-active-icon'></span> #} else {# <span class='k-icon ehors-status-inactive-icon'></span> #} #" },
{ field: "accountLedgerID", title:"Ledger Name", editor: getLedger,
template:" #= (data.accountLedgerID) ? kendo.toString (data.accountLedgerName): '' #" }]
PHP 插入
/* ADD */
function addGroup() {
global $ehorsObj;
$accountID = (isset($_POST['accountID']) ? $_POST['accountID'] : '');
$accountLedgerID = (isset($_POST['accountLedgerID']) ? $_POST['accountLedgerID'] : '');
/ check unique /
$sqlCount = "SELECT COUNT AS TOTAL FROM tblAccAccounts
WHERE accountID != '" . $accountID . "'
AND accountLedgerID = '" . $accountLedgerID . "'
";
$GetResult = $ehorsObj->FetchData($sqlCount, $ehorsObj->DEFAULT_PDO_CONNECTIONS);
while ($row = $GetResult->fetch()){
$total = $row ['TOTAL'];
}
if ($total == 0){
$accountID = $ehorsObj->EHORS_PK(tblAccAccounts);
$sqlAdd = "INSERT INTO tblAccAccounts
SET accountID = '" . $accountID . "',
accountLedgerID = '" . $accountLedgerID . "',
dateTimeEmployee = NOW() ";
$ehorsObj->ExecuteData($sqlAdd, $ehorsObj->DEFAULT_PDO_CONNECTIONS);
$accountLog = $ehorsObj->EHORS_PK(tblAccAccountsLog);
$sqlAddLog = "INSERT INTO tblAccAccountsLog
SET accountLog = '" . $accountLog . "',
accountID = '" . $accountID . "',
accountLedgerID = '" . $accountLedgerID . "',
dateTimeEmployee = NOW(),
active = 'y' ";
$ehorsObj->ExecuteData($sqlAddLog, $ehorsObj->DEFAULT_PDO_CONNECTIONS);
}else{
echo "Record already exist";
}}
如果你看到图片,列账名称上方的网格没有数据。它假设用户选择下拉菜单然后单击提交。之后,下拉列表中的选定数据将插入到网格中。希望任何人都可以对此提供任何参考。谢谢!
【问题讨论】:
标签: javascript php html kendo-grid