隐藏元素在剑道工具窗口基于按钮点击
Hiding elements in a Kendo Utility Window based on the button clicked
对这一切都比较陌生:我有一个剑道网格,其中客户Id是根据客户、年份和客户得到帮助的次数自动生成的。要用不同的地址或服务创建一个新的副本,它会打开一个实用程序窗口,你选择公司,它会生成Id,然后你填写字段。我还想使用它来更新客户记录,使用编辑按钮打开相同的实用程序窗口,但隐藏Pick company下拉,因为Id已经创建。
这是在主页上:
<script>
function closeWindow(e) {
$(this.element).empty();
}
function editJobs(e) {
e.preventDefault();
var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
var win = $("#utilityWindow").data("kendoWindow");
win.refresh({ url: "/BackendSchedule/_Jobs?jobId=" + dataItem.Id});
win.setOptions({
title: "Edit Jobs",
width: 1000,
height: 600,
});
win.center().open();
}
function newJobs() {
var win = $("#utilityWindow").data("kendoWindow");
win.refresh({ url: "/BackendSchedule/_Jobs?jobId="});
win.setOptions ({
title: "Add New Jobs",
width: 1000,
height: 600,
});
win.center().open();
}
Here is the Window
<form id="JobForm" class="form-horizontal">
<fieldset class="input">
<p class="info">
</p>
<p id="buildJobId" class="hidden">
<label for="storeType">Store Type</label>
@(Html.Kendo().DropDownList()
.Name("storeType")
.OptionLabel("please select")
.BindTo((SelectList)ViewData["jobtypes"])
.Events(e => e.Change("storeTypeChange"))
.HtmlAttributes(new { style = "width:275px;" })
)
</p>
<p>
<label for="Id">Id</label>
@Html.TextBoxFor(model => model.Id, new { @class = "k-textbox", @readonly = "readonly" })
</p>
<p>
<label for="Company">Company Name</label>
@(Html.Kendo().DropDownList()
.Name("Company")
.OptionLabel("Please Select")
.BindTo((SelectList)ViewData["company"])
.HtmlAttributes(new { style = "width:275px;" })
)
</p >
<p>
<label for="Address1">Address</label>
@Html.TextBoxFor(model => model.Address1, new { @class = "k-textbox" })<br/>
<p>
<label for="Address2"></label>
@Html.TextBoxFor(model => model.Address2, new { @class = "k-textbox" })
</p>
</p>
<p>
<label for="City">City</label>
@Html.TextBoxFor(model => model.City, new { @class = "k-textbox" })
</p>
<p>
<label for="State">State</label>
@(Html.Kendo().DropDownList()
.Name("State")
.OptionLabel("Please Select")
.BindTo((SelectList)ViewData["states"])
.HtmlAttributes(new { style = "width:200px;" })
)
</p>
<p>
<label for="ZipCode">Zip Code</label>
@Html.TextBoxFor(model => model.ZipCode, new { @class = "k-textbox" })
</p>
<p>
<label for="ContactName">Contact Name</label>
@Html.TextBoxFor(model => model.ContactName, new { @class = "k-textbox"})
</p>
<p>
<label for="Phone">Phone</label>
@Html.TextBoxFor(model => model.Phone, new { @class = "k-textbox", type = "tel" })
</p>
<p>
<label for="Email">Email</label>
@Html.TextBoxFor(model => model.Email, new { @class = "k-textbox", required = "required" })
</p>
<p>
<label for="TimeAllowed">Time Allowed</label>
@(Html.Kendo().NumericTextBoxFor(
</p>
<p>
<label for="PlanStartDate">Plan Start Date</label>
@(Html.Kendo().DatePickerFor(m => m.PlanStartDate))
</p>
<p>
<label for="PlanEndDate">Plan End Date</label>
@(Html.Kendo().DatePickerFor(m => m.PlanEndDate))
</p>
<p>
<label for="ReponsibleParty">Responsible Party</label>
@(Html.Kendo().DropDownList()
.Name("Contact")
.OptionLabel("Please Select")
.BindTo((SelectList)ViewData["responsibleParty"])
.HtmlAttributes(new { style = "width:300px;" })
)
</p>
<p>
<button class="k-button" id="submitForm" name="submitForm" type="submit">Submit</button>
<button class="k-button right" id="cancelButton" type="button">Cancel</button>
</p>
<div id="message" class="text-danger"></div>
</fieldset>
</form>
现在隐藏的Id=buildJobId将需要显示在create new按钮上。
下面是我认为可行的代码:
if ($("#Id").data("TextBoxFor").dataSource.data(null)){
$("#buildJobId").show();
} else {
$("#buildJobId").hide();
};
添加了更多的代码,但让它在最后一部分工作,我已将其连接到将被调用的函数:
$(document).ready(function() {
var validator = $("#JobForm").kendoValidator().data("kendoValidator");
var postUrl = "/BackendSchedule/Jobs_Update";
if ("@ViewBag.Id".length == 0) {
postUrl = "/BackendSchedule/Jobs_Create";
$("#buildJobId").show();
} else {
$("#buildJobId").hide();
}
相关文章:
- 为什么我的导航按钮或按钮文本不会移动到中心
- Javascript测验,有4个问题.单选按钮+继续按钮
- 使用两个按钮(提交按钮和普通按钮),它们应该以不同的方式提交相同的表单
- 如何通过单击另一个按钮使按钮可见
- 为什么jqueryUI按钮和按钮集的位置不同
- 单选按钮切换按钮问题
- Selenium Webdriver,单击一个不是真正按钮的按钮
- 我的加载更多功能适用于按钮单击,但它不适用于滚动
- AngularJS:ng-单击不起作用,适用于<按钮>
- 引导下拉列表永久显示 - 不特定于按钮单击
- 如何将函数应用于按钮
- onclick事件仅适用于按钮,而不适用于与按钮一起使用的glyphicon
- 类似于按钮不递增计数
- 如何制作切换按钮/反转按钮.类似于谷歌翻译
- 隐藏表列依赖于按钮在多个动态json数组键基于angularjs
- Bootstrap's弹出窗口只工作于按钮-不锚或跨度
- 获取表单中相对于按钮的输入值
- 我正在尝试生成一个随机颜色(javascript),并在单击按钮时将结果应用于按钮.如何将JS与Jquery结合起来
- Javascript函数作用于按钮点击,而不是在PHP echo
- 如何将jQuery样式应用于按钮