[webgrid] – header - (How to Add custom html to Header in WebGrid)
How to Add custom html to Header in WebGrid
Posted on March 30, 2013by mtryambake
How to make a MVC 3 Webgrid with checkbox column?
This article will show you a How to Add custom html to Header in WebGrid e.g. add a check box in webgrid header.
Some time you come across a situation where you have to add html element (checkbox) in webgrid header, consider a column with checkbox and you want to add checkbox in the header of same column.
Approach: In document.ready event find out webgrid header and replace it with html string.
$(document).ready(function () {
$('#gridContent table th').each(function () {
if (this.innerHTML == "") {
this.innerHTML = "<input type='checkbox' id='chkHeader' />";
}
});
});
Application: If you have a checkbox column in webgrid and on clicking of header checkbox all checkbox in column will be checked.
<script type="text/javascript">
$(document).ready(function () {
$('#gridContent table th').each(function () {
if (this.innerHTML == "") {
this.innerHTML = "<input type='checkbox' id='chkHeader' />";
}
});
$('#gridContent table th input:checkbox').click(function (e) {
var table = $(e.target).closest('table');
$('td input:checkbox', table).attr('checked', e.target.checked);
});
}); </script>
========================================================================================================
for reference
========================================================================================================
$(function () {
$('.gridTable thead tr th:first').html(
$('<input/>', {
type: 'checkbox',
click: function () {
var checkboxes = $(this).closest('table').find('tbody tr td input[type="checkbox"]');
checkboxes.prop('checked', $(this).is(':checked'));
}
})
);
});
[webgrid] – header - (How to Add custom html to Header in WebGrid)的更多相关文章
- Add custom and listview web part to a page in wiki page using powershell
As we know, Adding list view web part is different from custom web part using powershell, what's mor ...
- How To Add Custom Build Steps and Commands To setup.py
转自:https://jichu4n.com/posts/how-to-add-custom-build-steps-and-commands-to-setuppy/ A setup.py scrip ...
- Add custom daemon on Linux System
Ubuntu add custom service(daemon) Task 需要在系统启动的时候自动启动一个服务(后台程序),在系统关闭的时候关闭服务. 比如在部署某个应用之前,需要将某个任务设置成 ...
- RestTemplate发送请求并携带header信息 RestTemplate post json格式带header信息
原文地址: http://www.cnblogs.com/hujunzheng/p/6018505.html RestTemplate发送请求并携带header信息 v1.使用restTempl ...
- Add custom field in Material Master
1.Add fields in the Append Structure of table MARA. 2.Configure SPRO IMG -> Logistics General -&g ...
- grafana add custom dashboard
grafana-dashboard-json prometheus-operator helm 中的grafana dashboard 扩展的时候,需要转换下载(https://grafana.com ...
- [webgrid] – selecterow - (Get Selected Row from ASP.NET MVC 3 WebGrid)
Get Selected Row from ASP.NET MVC 3 WebGrid Abstract: The following article demonstrates how to get ...
- Umbrella Header for Module Bolts does not include header 'XXXXXX.h'?
在我们引入第三方Framwork时.有时会出现如标题的警告提示? 怎样解决? Framework 将在下面文件夹下创建一个Module/,并创建一个module.modulemap文件 waterma ...
- 开发Angular库的简单指导(译)
1. 最近工作上用到Angular,需要查阅一些英文资料,虽然英文非常烂,但是种种原因又不得不硬着头皮上,只是每次看英文都很费力,因此决定将一些比较重要的特别是需要反复阅读的资料翻译一下,以节约再次阅 ...
随机推荐
- 4位组合型Excel文档密码怎么破解
现代社会我们会遇到各种密码,很多的密码我们一段时间不用就不知不觉的忘记了.很多的excel用户就遇到过这种情况,这个时候我们就需要一款Excel密码破解工具.Advanced Office Passw ...
- phpwind9.0模板制作教程——制作论坛风格
由于论坛模板机制和门户等模板机制不同,所以今天我就先重点讲讲论坛模板制作的大概过程. 一.先来熟悉下phpwind9.0的论坛模板机制. 其实phpwind9.0的模板机制和discuzx2.5差不多 ...
- 升级ubuntu,apt-get update出现Hash Sum mismatch
sudo apt-get update 出现Hash Sum mismatch cd /var/lib/apt sudo rm -fr lists sudo mkdir lists sudo mkdi ...
- Python爬虫基础知识入门一
一.什么是爬虫,爬虫能做什么 爬虫,即网络爬虫,大家可以理解为在网络上爬行的一直蜘蛛,互联网就比作一张大网,而爬虫便是在这张网上爬来爬去的蜘蛛咯,如果它遇到资源,那么它就会抓取下来.比如它在抓取一个网 ...
- 初识echarts
show一个demo而已
- springMVC-InitBinder
-由@initBinder标识的方法,可以对webDataBinder对象进行初始化.WebDataBinder 的子类,用于完成由表单字段到javaBean属性的绑定 -@InitBinder方法不 ...
- 【bzoj2006】 NOI2010—超级钢琴
http://www.lydsy.com/JudgeOnline/problem.php?id=2006 (题目链接) 题意 给出一个数列,在其中选出K个长度在${[L,R]}$之间的不同的区间,使得 ...
- DIV横排/竖排滚动(white-space/::-webkit-scrollbar的使用技巧以及display: inline-block的选择)支持手势
参考微信的京东客户端http://wqs.jd.com/,实现DIV的横排滚动,且支持手势,并且不会出现滚动跳,效果如下: 但是观察其div结构是没有使用任何JS去实现. 一.实现上DIV的横排 观察 ...
- css中margin-top/margin-bottom失效
要设置这两个值,我的理解应该在这个div的父容器中设置了固定宽高,或者设置了绝对定位,比如position:absolute(绝对定位) 或者压根不用,直接用padding-top/padding-b ...
- ini_set()函数的使用 以及 post_max_size,upload_max_filesize的修改方法
Apache服务器处理: ini_set('display_errors', 'Off');ini_set('memory_limit', -1); //-1 / 10240Mini_set(&quo ...