网格kendoui中的复选框验证 [英] checkbox validation in grid kendoui

查看:150
本文介绍了网格kendoui中的复选框验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在网格中使用复选框,我正在从单独的表中获取combox并加入

在主表中.

我需要为此进行验证操作,所以请任何人

可以发送样品.


谢谢您,

Hi,

i am using checkbox in grid, i am getting the combox from seperate table and join

in the main table.

i need validation operation for that so please anyone

can sent sample.


Thank you,

推荐答案

使用javascrip的Gridview复选框验证 t

标签:Gridview,Javascript
简介:

您好,在这里,我将说明如何使用JavaScript在gridview中检查复选框的选中状态

说明:

我有一个带有复选框的gridview和一个按钮(如果用户单击按钮),如果用户没有在gridview中至少选中一个复选框,则需要进行验证,因为我编写了一个JavaScript函数来检查是否在gridview中选中了复选框.

为此,在aspx页面中编写以下代码

< html xmlns ="http://www.w3.org/1999/xhtml">
< head runat ="server">
< title>如果Header复选框选中了,则选中所有复选框</title>
< style type ="text/css">
.Gridview
{
font-family:Verdana;
font-size:10pt;
font-weight:normal;
颜色:黑色;
宽度:500像素;
}
</style>
< script type ="text/javascript" language ="javascript">
函数validateCheckBoxes(){
var isValid = false;
var gridView = document.getElementById(''<%= gvcheckbox.ClientID%>''));
for(var i = 1; i< gridView.rows.length; i ++){
var输入= gridView.rows [i] .getElementsByTagName("input");
if(inputs!= null){
if(inputs [0] .type =="checkbox"){
if(inputs [0] .checked){
isValid = true;
返回true;
}
}
}
}
alert(请至少选择一个复选框");
返回false;
}
</script>
</head>
< body>
< form id ="form1" runat ="server">
Gridview checkbox validation using javascript

Labels: Gridview, Javascript
Introduction:

Hi here I will explain how to check the checked status of checkboxes in gridview using JavaScript

Description:

I have a one gridview with checkboxes and one button if user clicks on button I need to raise validation if user doesn’t checked at least one checkbox in gridview for that I have written one JavaScript function to check whether checkboxes selected in gridview or not.

For that write the following code in aspx page

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Check all checkboxes if Header checkbox checks</title>
<style type="text/css">
.Gridview
{
font-family:Verdana;
font-size:10pt;
font-weight:normal;
color:black;
width:500px;
}
</style>
<script type="text/javascript" language="javascript">
function validateCheckBoxes() {
var isValid = false;
var gridView = document.getElementById(''<%= gvcheckbox.ClientID %>'');
for (var i = 1; i < gridView.rows.length; i++) {
var inputs = gridView.rows[i].getElementsByTagName(''input'');
if (inputs != null) {
if (inputs[0].type == "checkbox") {
if (inputs[0].checked) {
isValid = true;
return true;
}
}
}
}
alert("Please select atleast one checkbox");
return false;
}
</script>
</head>
<body>
<form id="form1" runat="server">

< asp:gridview id ="gvcheckbox" cssclass ="Gridview" runat ="server" autogeneratecolumns ="False" xmlns:asp =#unknown">
HeaderStyle-BackColor =#7779AF" HeaderStyle-ForeColor ="white">
<列>< asp:templatefield>
< HeaderTemplate>
< asp:checkbox id ="chkheader" runat ="server"/>
</HeaderTemplate>
< itemtemplate>
< asp:checkbox id ="chkchild" runat ="server"/>

< HeaderStyle Horizo​​ntalAlign ="Left"/>
< itemstyle horizo​​ntalalign ="Left">

< asp:boundfield headertext ="UserName" datafield ="UserName" headerstyle-horizo​​ntalalign ="Left"/>
< asp:boundfield headertext ="FirstName" datafield ="FirstName" headerstyle-horizo​​ntalalign ="Left"/>
< asp:boundfield headertext ="LastName" datafield ="LastName" headerstyle-horizo​​ntalalign ="Left"/>
< asp:button runat ="server" text ="Submit" onclientclick ="javascript:validateCheckBoxes()" xmlns:asp =#unknown"/>

<asp:gridview id="gvcheckbox" cssclass="Gridview" runat="server" autogeneratecolumns="False" xmlns:asp="#unknown">
HeaderStyle-BackColor="#7779AF" HeaderStyle-ForeColor="white">
<columns><asp:templatefield>
<HeaderTemplate>
<asp:checkbox id="chkheader" runat="server" />
</HeaderTemplate>
<itemtemplate>
<asp:checkbox id="chkchild" runat="server" />

<HeaderStyle HorizontalAlign="Left" />
<itemstyle horizontalalign="Left">

<asp:boundfield headertext="UserName" datafield="UserName" headerstyle-horizontalalign="Left" />
<asp:boundfield headertext="FirstName" datafield="FirstName" headerstyle-horizontalalign="Left" />
<asp:boundfield headertext="LastName" datafield="LastName" headerstyle-horizontalalign="Left" />
<asp:button runat="server" text="Submit" onclientclick="javascript:validateCheckBoxes()" xmlns:asp="#unknown" />


</form>
</body>
</html>

在将gridview与一些数据绑定在一起的代码中,并检查它是否对您有用

演示!


</form>
</body>
</html>

In code behind bind gridview with some data and check it will work for you

DEMO!


这篇关于网格kendoui中的复选框验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆