gpt4 book ai didi

javascript - 修改 w2ui 插件

转载 作者:行者123 更新时间:2023-11-30 18:01:51 24 4
gpt4 key购买 nike

我正在使用 w2ui( http://w2ui.com/ ) 插件。

考虑这个例子:1

  1. 我希望在单击添加按钮时在网格中出现一个空的可编辑行以添加新行?

  2. 我没有找到隐藏搜索框的配置,如何隐藏它?

  3. 如何将列设置为 id?目前它只能识别recid

最佳答案

以下是单击按钮时如何在网格中添加新记录的示例:

    <html>
<head>
<link rel="stylesheet" type="text/css" media="screen" href="../css/w2ui.css" />
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script type="text/javascript" src="../js/w2ui.js"></script>
<script>
$(function () {
$('#grid').w2grid({
name: 'grid',
show: {
toolbar: true,
footer: true,
header: true,
columnHeaders: true,
lineNumbers: true,
toolbarDelete: true,
toolbarSave: true,
toolbarAdd: true
},
columns: [
{ field: 'recid', caption: 'ID', size: '50px', sortable: true, resizable: true, searchable: 'int' },
{ field: 'lname', caption: 'Last Name', size: '30%', sortable: true, resizable: true, searchable: true,
editable: { type: 'text' }
},
{ field: 'fname', caption: 'First Name', size: '30%', sortable: true, resizable: true, searchable: true,
editable: { type: 'text' }
},
],
onAdd: function (target, data) {
var recid = 1;
if (this.records.length > 0) recid = (Math.max.apply(Math, this.find({}))) + 1;
this.add({ recid: recid });
$('#grid_grid_edit_'+ (this.records.length - 1) +'_1').focus();
},
onSave: function (target, data) {
var obj = this;
console.log(data);
data.onComplete = function () {
for (var r in data.changed) {
obj.get(data.changed[r].recid).editable = false;
}
obj.refresh();
}
}
});
});
</script>
</head>
<body>
<div id="grid" style="width: 100%; height: 500px;"></div>
</body>
</html>

关于javascript - 修改 w2ui 插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16790988/

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