gpt4 book ai didi

javascript - 数据表编辑器不发送 ID

转载 作者:行者123 更新时间:2023-12-03 08:43:43 26 4
gpt4 key购买 nike

我需要更新 mysql 中的数据,并且我正在使用数据表内联编辑扩展。我需要解决的问题是,如何发送行的id、字段的名称和单元格的值。这是它发送的数据;我得到:

 data[undefined][player_nickname]:Leon

但我需要:

data[1][player_nickname]:Rafantunessdds

这是我的 js 代码:

editor = new $.fn.dataTable.Editor({
table: "#dtables",
ajax: {
edit: {
type: 'GET',
url: '<?php echo site_url(); ?>players/saveUserData'
},
},
fields: [{
label: "Nickname:",
name: "player_nickname"
}, {
label: "Email:",
name: "player_email"
}, {
label: "Password:",
name: "player_password"
},
{
label: "Is Admin:",
name: "is_admin"
},
{
label: "Is Moderator:",
name: "is_moderator"
},
{
label: "is Manager:",
name: "is_manager"
},
{
label: "is Premiun:",
name: "player_premium"
},
{
label: "Is banned:",
name: "player_banned"
},
]
});
editor = new $.fn.dataTable.Editor({
ajax: "players/saveuserdata.php",
table: ".dtables",
fields: [{
label: "Nickname:",
name: "player_nickname"
}, {
label: "Email:",
name: "player_email"
}, {
label: "Password:",
name: "player_password"
},
{
label: "Is Admin:",
name: "is_admin"
},
{
label: "Is Moderator:",
name: "is_moderator"
},
{
label: "is Manager:",
name: "is_manager"
},
{
label: "is Premiun:",
name: "player_premium"
},
{
label: "Is banned:",
name: "player_banned"
},
]
});

$('.dtables').on('click', 'tbody td:not(:first-child)', function (e) {
editor.inline(this);
});
$('.dtables').DataTable({

data: <?php echo($players) ?>,
columns: [
{data: 'player_id'},
{data: 'player_nickname'},
{data: 'player_email'},
{data: 'player_password'},
{data: 'is_admin'},
{data: 'is_moderator'},
{data: 'is_manager'},
{data: 'player_premium'},
{data: 'player_banned'}

]
});

如何发送行的 ID?

最佳答案

使用idSrc JSON 属性 rom,用于读取/写入行的 ID 属性。

idSrc: "player_id"

关于javascript - 数据表编辑器不发送 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32979227/

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