gpt4 book ai didi

javascript - 将 HTML 表单中的数据插入到 Kendo 网格数据中

转载 作者:行者123 更新时间:2023-11-28 02:21:07 25 4
gpt4 key购买 nike

我尝试在下拉列表中选择数据,然后提交到剑道网格中。但是,数据未能插入到网格中。有人有想法或解决方案吗?

HTML submit button

<button class="k-button" id="btnSave" value="submit" style="float:right; padding: 5px 20px; border-radius: 4px;" >Submit</button>

JavaScript button submit

    //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 dropdown

        $("#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 Kendo Grid

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 Insert

   /* 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";
}}

这是我的输出 enter image description here

如果你看到图片,列分类帐名称上方的网格没有数据。它假设用户选择下拉菜单然后单击提交。之后,下拉列表中选定的数据将被插入到网格中。希望任何人都可以对此提供任何引用。谢谢!

最佳答案

应该有 : { 在你的代码中 'transport' 和 'read' 之后。

下面这部分代码修复了:

dataSource: {
transport: {
read: {
url: "./getCoaGroup.php",
type: "POST",
data: function() {
return {
method: "getAccLedger",
}
}
},
},

关于javascript - 将 HTML 表单中的数据插入到 Kendo 网格数据中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57549695/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com