gpt4 book ai didi

javascript - Kendo UI Tabstrip : Tab should render a grid after clicking on a button inside that tab

转载 作者:行者123 更新时间:2023-11-28 03:16:14 26 4
gpt4 key购买 nike

我有一个带有两个选项卡的选项卡条。在第一个选项卡中,我有名为“显示网格”的按钮。单击该按钮后,它将呈现一个网格以及一个后退按钮,以返回到仅包含“显示网格”按钮的上一个 View 。问题是我如何使用这个后退按钮返回?

<body>

<div id="tabstrip">
<ul>
<li id="tab1">Tab 1</li>
<li id="tab2">Tab 2</li>
</ul>
<div>
<button class='k-button'>Show grid</button>
<div id="button1"></div>
<div id="grid"></div>
</div>
<div>Content 2</div>
</div>

<script>


function grid() {
$("#grid").kendoGrid({
columns: [
{ field: "name" },
{ field: "age" }
],
dataSource: {
data: [
{ name: "Jane Doe", age: 30 },
{ name: "John Doe", age: 33 }
]
}
});
}

var tabStrip = $("#tabstrip").kendoTabStrip().data("kendoTabStrip");

$(".k-button").one("click", function() {
$("#button1").append('<button>Click</button>');
grid();
});

</script>
</body>

最佳答案

尝试this ,在本例中我使用了相同的按钮,但是按照相同的逻辑,您可以创建一个新按钮,同时保留这两个按钮

var tabStrip = $("#tabstrip").kendoTabStrip().data("kendoTabStrip");
var flag = true;



$("#grid").kendoGrid({
columns: [
{ field: "name" },
{ field: "age" }
],
dataSource: {
data: [
{ name: "Jane Doe", age: 30 },
{ name: "John Doe", age: 33 }
]
}
}).hide();



$(".k-button").click(function () {
if(flag === true){
$("#grid").show();
$(".k-button").text("Remove grid");
flag = false;
} else {
$("#grid").hide();
$(".k-button").text("Show grid");
flag = true;
}
});
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled</title>

<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2018.3.1017/styles/kendo.common.min.css">
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2018.3.1017/styles/kendo.rtl.min.css">
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2018.3.1017/styles/kendo.default.min.css">
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2018.3.1017/styles/kendo.mobile.all.min.css">

<script src="https://code.jquery.com/jquery-1.12.3.min.js"></script>
<script src="https://kendo.cdn.telerik.com/2018.3.1017/js/angular.min.js"></script>
<script src="https://kendo.cdn.telerik.com/2018.3.1017/js/jszip.min.js"></script>
<script src="https://kendo.cdn.telerik.com/2018.3.1017/js/kendo.all.min.js"></script>

<style>
.k-edit-form-container { width: 500px;}
.k-popup-edit-form .k-edit-label { width: 20%; text-align: left; }
.k-popup-edit-form .k-edit-field { width: 70%; }
.k-popup-edit-form .k-edit-field > .k-textbox,
.k-popup-edit-form .k-edit-field > .k-widget:not(.k-tooltip)
{ width: 98%; }
</style>
</head>
<body>

<div id="tabstrip">
<ul>
<li id="tab1">Tab 1</li>
<li id="tab2">Tab 2</li>
</ul>
<div>
<button class='k-button'>Show grid</button>
<div id="button1"></div>
<div id="grid"></div>
</div>
<div>Content 2</div>
</div>


</body>
</html>

关于javascript - Kendo UI Tabstrip : Tab should render a grid after clicking on a button inside that tab,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59626978/

26 4 0
文章推荐: javascript - 如何在 Javascript 中创建单例类?
文章推荐: html - 在
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com