Jquery 复选框总是未选中

Jquery 复选框总是未选中,jquery,asp.net-mvc,kendo-ui,kendo-grid,telerik-mvc,Jquery,Asp.net Mvc,Kendo Ui,Kendo Grid,Telerik Mvc,我有以下与jQuery关联的剑道网格ans。单击按钮时,我需要知道是否选中了复选框。但目前它总是表现出“假”。我们怎样才能纠正它 @Scripts.Render("~/bundles/jquery") <script type="text/javascript"> $(document).ready(function () { $('#btnMove').click(function () { var sourcegri

我有以下与jQuery关联的剑道网格ans。单击按钮时,我需要知道是否选中了复选框。但目前它总是表现出“假”。我们怎样才能纠正它

@Scripts.Render("~/bundles/jquery")
<script type="text/javascript">

    $(document).ready(function ()
    {

        $('#btnMove').click(function () {


            var sourcegrid = $('#GridParent').data('kendoGrid');        //SOURCE GRID
            var destinationgrid = $('#ChildGrid').data('kendoGrid'); // DESTINATION GRID

            alert('Button Clicked');

            var grid = $("#GridParent").data("kendoGrid");
            var datatItem = grid.dataItem(grid.tbody.find('tr:eq(2)'));
            var selectedTd = $(datatItem).find('td:eq(0)').is(':checked');
            alert(selectedTd);

            //destinationgrid.dataSource.add(datatItem);

</script>
@model IEnumerable<KendoPratapSampleMVCApp.Models.StudentDetails>
@{
    ViewBag.Title = "Index";
}

<h2>Index</h2>
@using (Html.BeginForm())
{ 
    @(Html.Kendo().Grid<KendoPratapSampleMVCApp.Models.StudentDetails>()    
    .Name("GridParent")
    .Columns(columns => {
        columns.Bound(p => p.studentclass).HeaderTemplate("<input id='selectall' class='chkbx' type='checkbox' onclick='ToggleChkBox(this.checked);' />").ClientTemplate("<input id='checkbox' onclick='grdChkBoxClick(this); ' class='chkbxq' type='checkbox' />").Sortable(false).Filterable(false).Width(30);
        columns.Bound(p => p.studentId).Filterable(false).Width(90);
        columns.Bound(p => p.studentName).Filterable(false).Width(90);
        columns.Bound(p => p.StudentBranch).Filterable(false).Width(90);

    })
    .Pageable()
    .Sortable()
    .Scrollable()
    .Filterable()
    .Resizable(resize => resize.Columns(true))
    .Reorderable(reorder => reorder.Columns(true))
    .Selectable(s => s.Mode(GridSelectionMode.Multiple))
    .HtmlAttributes(new { style = "height:250px;" })
    .DataSource(dataSource => dataSource
        .Ajax()
        .PageSize(20)
        .Read(read => read.Action("Orders_Read", "StudentDtls"))
     )
  )

    <input id="btnMove" type="button" value="Move" />
@Scripts.Render(“~/bundles/jquery”)
$(文档).ready(函数()
{
$('#btnMove')。单击(函数(){
var sourcegrid=$('#GridParent').data('kendoGrid');//源网格
var destinationgrid=$('#ChildGrid').data('kendoGrid');//目标网格
警报(“点击按钮”);
var grid=$(“#GridParent”).data(“kendoGrid”);
var datatItem=grid.dataItem(grid.tbody.find('tr:eq(2)');
var selectedTd=$(datatItem).find('td:eq(0)').is(':checked');
警报(已选择d);
//destinationgrid.dataSource.add(datatItem);
@模型IEnumerable
@{
ViewBag.Title=“Index”;
}
指数
@使用(Html.BeginForm())
{ 
@(Html.Kendo().Grid())
.名称(“家长”)
.列(列=>{
columns.Bound(p=>p.studentclass).HeaderTemplate(“”).ClientTemplate(“”).Sortable(false).Filterable(false).Width(30);
columns.Bound(p=>p.studentId).Filterable(false).Width(90);
columns.Bound(p=>p.studentName).Filterable(false).Width(90);
columns.Bound(p=>p.StudentBranch).Filterable(false).Width(90);
})
.Pageable()
.Sortable()
.Scrollable()
.可过滤()
.resize可调整大小(resize=>resize.Columns(true))
.Reorderable(reorder=>reorder.Columns(true))
.可选(s=>s.Mode(GridSelectionMode.Multiple))
.HtmlAttributes(新的{style=“height:250px;”})
.DataSource(DataSource=>DataSource
.Ajax()
.页面大小(20)
.Read(Read=>Read.Action(“Orders\u Read”,“StudentDtls”))
)
)
更新:图片

编辑:HTML标记

  <h2>Index</h2>
    <form action="/StudentDtls" method="post"><div class="k-widget&#32;k-grid" id="GridParent" style="height:250px;"><div class="k-grid-header"><div class="k-grid-header-wrap"><table><colgroup><col style="width:30px" /><col style="width:90px" /><col style="width:90px" /><col style="width:90px" /></colgroup><tr><th class="k-header" data-field="studentclass" data-title="studentclass" scope="col"><input id='selectall' class='chkbx' type='checkbox' onclick='ToggleChkBox(this.checked);' /></th><th class="k-header" data-field="studentId" data-title="student&#32;Id" scope="col"><a class="k-link" href="/StudentDtls/Orders_Read?GridParent-sort=studentId-asc">student Id</a></th><th class="k-header" data-field="studentName" data-title="student&#32;Name" scope="col"><a class="k-link" href="/StudentDtls/Orders_Read?GridParent-sort=studentName-asc">student Name</a></th><th class="k-header" data-field="StudentBranch" data-title="Student&#32;Branch" scope="col"><a class="k-link" href="/StudentDtls/Orders_Read?GridParent-sort=StudentBranch-asc">Student Branch</a></th></tr></table></div></div><div class="k-grid-content" style="height:200px"><table><colgroup><col style="width:30px" /><col style="width:90px" /><col style="width:90px" /><col style="width:90px" /></colgroup><tbody><tr class="t-no-data"><td colspan="4"></td></tr></tbody></table></div><div class="k-pager-wrap&#32;k-grid-pager"><a class="k-link&#32;k-state-disabled" data-page="1" href="#" title="Go&#32;to&#32;the&#32;first&#32;page"><span class="k-icon&#32;k-i-seek-w">seek-w</span></a><a class="k-link&#32;k-state-disabled" data-page="0" href="#" title="Go&#32;to&#32;the&#32;previous&#32;page"><span class="k-icon&#32;k-i-arrow-w">arrow-w</span></a><ul class="k-pager-numbers&#32;k-reset"><li><span class="k-state-selected" data-page="1">1</span></li></ul><a class="k-link&#32;k-state-disabled" data-page="2" href="#" title="Go&#32;to&#32;the&#32;next&#32;page"><span class="k-icon&#32;k-i-arrow-e">arrow-e</span></a><a class="k-link&#32;k-state-disabled" data-page="1" href="#" title="Go&#32;to&#32;the&#32;last&#32;page"><span class="k-icon&#32;k-i-seek-e">seek-e</span></a><span class="k-pager-info&#32;k-label">No items to display</span></div></div><script>
        jQuery(function(){jQuery("#GridParent").kendoGrid({"columns":[{"title":"studentclass","width":"30px","template":"\u003cinput id=\u0027checkbox\u0027 onclick=\u0027grdChkBoxClick(this); \u0027 class=\u0027chkbxq\u0027 type=\u0027checkbox\u0027 /\u003e","field":"studentclass","sortable":false,"filterable":false,"encoded":true},{"title":"student Id","width":"90px","field":"studentId","filterable":false,"encoded":true},{"title":"student Name","width":"90px","field":"studentName","filterable":false,"encoded":true},{"title":"Student Branch","width":"90px","field":"StudentBranch","filterable":false,"encoded":true}],"pageable":{"buttonCount":10},"sortable":true,"selectable":"Multiple, Row","filterable":true,"resizable":true,"reorderable":true,"dataSource":{"transport":{"prefix":"","read":{"url":"/StudentDtls/Orders_Read"}},"pageSize":20,"page":1,"total":0,"serverPaging":true,"serverSorting":true,"serverFiltering":true,"serverGrouping":true,"serverAggregates":true,"type":"aspnetmvc-ajax","filter":[],"schema":{"data":"Data","total":"Total","errors":"Errors","model":{"fields":{"studentId":{"type":"string"},"studentName":{"type":"string"},"StudentBranch":{"type":"string"},"studentclass":{"type":"number"}}}}}});});
索引
无需显示任何项目
jQuery(function(){jQuery(“#GridParent”).kendoGrid({“columns”):[{“title”:“studentclass”,“width”:“30px”,“template”:“\u003cinput id=\u0027checkbox\u0027 onclick=\u0027grdChkBoxClick(this);\u0027 class=\u0027chkbxq\u0027 type=\u0027 checkbox\u0027/\u003e”,“field:“studentclass”,“sortable”;“false”,“filteable”;“false”,“true”,“宽度”:“90px”,“字段”:“studentId”,“filterable”:false,“encoded”:true},{“title”:“studentName”,“filterable”:false,“encoded”:true},{“title”:“StudentBranch”,“width”:“90px”,“field”:“StudentBranch”,“filterable”:false,“encoded”:true}],“pageable”:{“buttonCount”:10},“sortable”:true,“selectable”:“Multiple,Row”,“可选”:filterable“,”resizable“,”true“,”reorderable“,”true“,”dataSource“:{”传输“,”读取“,”url“,”StudentDtls/Orders_read“}”,pageSize“,”20,“page“,”page“,”1,“total“,”0,“serverPaging“,”true,“serverSorting“,”true,“serverGrouping“,”true,“serverGrouping“,”type“:”aspnetmvc ajax”,“filter“,”模式“:”,”data“,”data“,”总计“:”总计,“错误”:“错误”,“模型”:{“字段”:{“studentId”:{“类型”:“字符串”},“studentName”:{“类型”:“字符串”},“StudentBranch”:{“类型”:“字符串”},“studentclass”:{“类型”:“数字”};});
您好,请尝试此代码

 $('#Submit1').click(function () {

            var grid = $("#grid12").data("kendoGrid");
            var selected = grid.tbody.find('td').find('.chkbxq').is(':checked');
            var checkid = grid.tbody.find('td').find('.chkbxq').attr('id');
            var cellIndex = grid.tbody.find('td').find('.chkbxq:checked').parent().index();
            var rowIndex = grid.tbody.find('td').find('.chkbxq:checked').parent().parent().index();
            var dataitem = grid.dataItem(grid.tbody.find('tr:eq(' + rowIndex + ')'));

            sampleItem = dataitem.SampleItems;
            sampleCode = dataitem.SampleCode;
            sampledescription = dataitem.SampleDescription;

            alert(sampleItem + "--" + sampleCode + "--" + sampledescription);

        });
我的网格

 <input id="Submit1" type="button" value="SubmitValue" />
 @(Html.Kendo().Grid<TwoModelInSinglePageModel.SampleModel>()
    .Name("grid12")
    .Columns(columns =>
    {
        columns.Bound(p => p.studentclass).HeaderTemplate("<input id='selectall' class='chkbxq' type='checkbox'  />").ClientTemplate("<input id='checkbox' class='chkbxq' type='checkbox' />");
        columns.Bound(p => p.SampleDescription);
        columns.Bound(p => p.SampleCode);
        columns.Bound(p => p.SampleItems);
    })
        .AutoBind(true) // here I am disabling automatic binding at page load
       .DataSource(dataSource => dataSource
        .Ajax()
            .Read(read => read.Action("Read", "Test"))
     )
  )

@(Html.Kendo().Grid())
.名称(“grid12”)
.列(列=>
{
columns.Bound(p=>p.studentclass).HeaderTemplate(“”).ClientTemplate(“”);
columns.Bound(p=>p.SampleDescription);
columns.Bound(p=>p.SampleCode);
columns.Bound(p=>p.SampleItems);
})
.AutoBind(true)//这里我禁用了页面加载时的自动绑定
.DataSource(DataSource=>DataSource
.Ajax()
.Read(Read=>Read.Action(“Read”,“Test”))
)
)

您正在应用的IDY直接访问
is(“:选中”)
on
td
元素不在复选框上哦,好的,事实上,当我们选中复选框,然后按下按钮,我需要移动到另一个网格上,这就是我想用该selcetdTd做的事……但我一直在寻找选中的复选框,并为thatTushar的answe获取相应的数据r是正确的。需要进行一些修改,但只能在查看生成的HTML@anu我已经使用了下面的代码,但我还是得到了错误…非常感谢jaimin…我现在可以得到它…但是我需要选中相应复选框的dataitem…我如何得到它…我已经使用了这个属性。…这正在工作
var dataitem=grid.dataitem(grid.tbody.find('tr:eq('+rowIndex+'))'
…非常感谢