Telerik Kendo --Grid之CheckBox 多选 toolbar监听编辑(ASP.NET MVC)
来源:互联网 发布:手机麻将软件制作 编辑:程序博客网 时间:2024/04/27 23:43
备注:主要介绍的是其中一种思路,代码可能有部分不全或者失误
CHTML:
<span style="color:#009900;"><!-- list--></span> <div id="myGrid"></div>
<span style="color:#006600;"><!--toolBar--></span><script id='cust_toolbar' type='text/x-kendo-template'> <div class="col-md-10 clear-padding"> <a class="k-button k-button-icontext k-grid-add k-cust-add" data-resx="text:addNewSchedule"> <span class="k-icon k-add"></span>Add New Schedule </a> </div> <div class="col-md-2 clear-padding"> <a class="k-button k-button-icontext k-grid-delete k-cust-delete"> <span class="k-icon k-delete"></span>Remove </a> <a class="k-button k-button-icontext k-grid-update k-cust-edit"> <span class="k-icon k-edit"></span>Clone </a> </div> </script>
JS:
初始化kendo grid 表:
//initial Telerik Grid control var gridDataSource = new kendo.data.DataSource({ data: someDateObject, pageSize: 15 }); var $myGrid = $("#myGrid"); $myGrid.kendoGrid({ toolbar: [ { template: kendo.template($("#cust_toolbar").html()) } ], dataSource: gridDataSource, height: 500, groupable: true, sortable: true, filterable: { extra: false }, pageable: { refresh: true, pageSizes: true, buttonCount: 5 }, columns: [ { field: "ProductName", title: "Name", width: 300, filterable: true, template: '<a href="/Schedule/Edit/#= ID #">#= ProductName #</a>' }, { field: "Location", title: "Location", width: 400, filterable: true, }, { field: "EffectiveDate", title: "Date", width: 200, filterable: true, }, { title: " ", //checkbox width: 150, template: "<input class='check_row' value='#= ID #' type='checkbox' />", filterable: false }], });
checkbox 监听:(监听checkbox的选定状态disable和enable两个按钮(.k-cust-edit, .k-cust-delete))
$(".check_row").change(function () { app.schedule.selRows = $(".check_row:checked"); if (app.schedule.selRows.length === 0) { $(".k-cust-edit").addClass("not-active"); $(".k-cust-delete").addClass("not-active"); } else { if ($(".k-cust-edit").hasClass("not-active")) { $(".k-cust-edit").removeClass("not-active"); } if ($(".k-cust-delete").hasClass("not-active")) { $(".k-cust-delete").removeClass("not-active"); } } });
css: not-active
.not-active { pointer-events: none; cursor: default;}
toolbar 按钮监听:
//Reomve the selected records $(".k-cust-delete", grid.element).off('click').on("click", function (ev) { selRows = $(".check_row:checked"); //do something.. } }); $(".k-cust-edit").addClass("not-active"); //Clone the selected records $(".k-cust-edit", grid.element).off('click').on("click", function (ev) { app.schedule.selRows = $(".check_row:checked"); //do something.. } });
0 0
- Telerik Kendo --Grid之CheckBox 多选 toolbar监听编辑(ASP.NET MVC)
- Asp.net mvc Kendo UI Grid的使用(二)
- Asp.net mvc Kendo UI Grid的使用(三)
- MVC Kendo总结之-----> Grid
- MVC Kendo总结之-----> CheckBox
- [Asp.net mvc] Asp.net mvc Kendo UI Grid的使用(四)
- MVC kendo Grid EditorTemplate
- 一个Asp.net MVC 控件项目分析---Telerik.Web.Mvc
- 一个Asp.net MVC 控件项目分析---Telerik.Web.Mvc
- MVC Kendo总结之-----> Grid(Edit、Cancel、Save、First、Prev、Next、Last)
- Telerik Extensions for ASP.NET MVC 中文教程(1)
- Telerik Extensions for ASP.NET MVC 中文教程(2)
- Kendo UI ASP.NET MVC使用教学视频集锦(高清在线观看)
- ASP.NET MVC 4中使用Kendo UI
- ASP.NET MVC 4中使用Kendo UI
- Kendo UI for ASP.NET MVC 的一些使用经验
- Kendo Grid MVC Hierarchy with Aggregate
- telerik asp.net 控件学习笔记之————ComboBox(DropDownList)
- 构造函数和析构函数的执行顺序相反
- 网络基本功(三):细说VLAN与Trunk
- USACO5.1.3 Musical Themes(theme)
- Eclipse无法编译的原因——写给初学者
- iOS-核心动画高级编程/15-图层性能
- Telerik Kendo --Grid之CheckBox 多选 toolbar监听编辑(ASP.NET MVC)
- Android仿美团加载数据、小人奔跑进度动画对话框(附顺丰快递员奔跑效果)
- 如何在SharePoint中配置和自定义Content Query Web Part(一)
- Sum Root to Leaf Numbers
- Ubuntu问题:Syntax error: Bad for loop variable
- operator new 与 new operator
- c3p0的重连机制详解
- gradle -- 依赖管理
- Android资料指南dr