How to Add custom html to Header in WebGrid

MyEvernote Link

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)的更多相关文章

  1. 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 ...

  2. 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 ...

  3. Add custom daemon on Linux System

    Ubuntu add custom service(daemon) Task 需要在系统启动的时候自动启动一个服务(后台程序),在系统关闭的时候关闭服务. 比如在部署某个应用之前,需要将某个任务设置成 ...

  4. RestTemplate发送请求并携带header信息 RestTemplate post json格式带header信息

    原文地址:  http://www.cnblogs.com/hujunzheng/p/6018505.html RestTemplate发送请求并携带header信息   v1.使用restTempl ...

  5. Add custom field in Material Master

    1.Add fields in the Append Structure of table MARA. 2.Configure SPRO IMG -> Logistics General -&g ...

  6. grafana add custom dashboard

    grafana-dashboard-json prometheus-operator helm 中的grafana dashboard 扩展的时候,需要转换下载(https://grafana.com ...

  7. [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 ...

  8. Umbrella Header for Module Bolts does not include header &#39;XXXXXX.h&#39;?

    在我们引入第三方Framwork时.有时会出现如标题的警告提示? 怎样解决? Framework 将在下面文件夹下创建一个Module/,并创建一个module.modulemap文件 waterma ...

  9. 开发Angular库的简单指导(译)

    1. 最近工作上用到Angular,需要查阅一些英文资料,虽然英文非常烂,但是种种原因又不得不硬着头皮上,只是每次看英文都很费力,因此决定将一些比较重要的特别是需要反复阅读的资料翻译一下,以节约再次阅 ...

随机推荐

  1. java-原生爬虫机制源码

    这是一个web搜索的基本程序,从命令行输入搜索条件(起始的URL.处理url的最大数.要搜索的字符串),它就会逐个对Internet上的URL进行实时搜索,查找并输出匹配搜索条件的页面. 这个程序的原 ...

  2. 回到顶端js实现

    function goTop(){ var _btn = document.getElementById("goTop"); if (document.documentElemen ...

  3. 怎么给我的Office文档加密

    很多的用户朋友都可以熟练的使用office中的Word.Excel和PowerPoint文档,但大家对Office文档加密方式了解的并不多.Advanced Office Password Recov ...

  4. 【POJ 2528】Mayor’s posters(线段树+离散化)

    题目 给定每张海报的覆盖区间,按顺序覆盖后,最后有几张海报没有被其他海报完全覆盖.离散化处理完区间端点,排序后再给相差大于1的相邻端点之间再加一个点,再排序.线段树,tree[i]表示节点i对应区间是 ...

  5. 【转】wait,notify,notifyAll,join,yield,sleep的区别和联系

    1.  Thread.sleep(long) 和Thread.yield()都是Thread类的静态方法,在调用的时候都是Thread.sleep(long)/Thread.yield()的方式进行调 ...

  6. bbs树形打印(一)

    前言:大家在bbs回帖时常常可以看到树形的回复形式. dfs设计 (1) 为使得Connection仅打开一次,因此以conn作为其中一个递归参数,在递归全程不关闭conn; (2)根据存入数据的树状 ...

  7. python编程关键字

    1.常见关键字 (带有操作含义的关键字) for:循环 in:成员比较运算符 if :如果分支 elif:如果分支 else:其他分支 while:循环 def:定义函数 class:定义类 glob ...

  8. [日常训练]常州集训day7

    T1 Description 给定一个序列,初始为空.依次将$1-n$插入序列,其中$i$插到当前第$a_i$个数的右边($a_i=0$表示插到序列最左边).求最终序列. Input 第一行一个整数$ ...

  9. Leetcode Odd Even Linked List

    Given a singly linked list, group all odd nodes together followed by the even nodes. Please note her ...

  10. Input path does not exist: file:/.......

    注意看是file不存在并不是hdfs,好奇怪,突然明白应该是路径不对,必须加上hdfs://hostname:port/file. 我为什么饭这样的错误是因为前一阵谢了HDFS的曹组,谢了全局File ...