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. dede使用方法----调用列表页的分页功能

    分页的标签:<div class="dede_pages"> <ul class="pagelist"> {dede:pagelist ...

  2. Web前端性能优化教程01:减少Http请求

    性能黄金法则 只有10%-20%的最终用户响应时间花在接收请求的HTML文档上,剩下的80%-90%时间花在HTML文档所引用的所有组件(图片,script,css,flash等等)进行的HTTP请求 ...

  3. Xcode找不到模拟器出现"My Mac"

    问题如图: 步骤一. 找到target->built settings->Architectures->Base SDK, 选择你需要的版本;如果还是不行,看步骤二. 步骤二. 1) ...

  4. 算法与数据结构之选择排序(C语言)

    #include<stdio.h> #include<stdlib.h> void SelectSort(int *a,int n);//预声明要调用的函数 int main( ...

  5. android开发之自定义组件

    android开发之自定义组件 一:自定义组件: 我认为,自定义组件就是android给我们提供的的一个空白的可以编辑的图片,它帮助我们实现的我们想要的界面,也就是通过自定义组件我们可以把我们要登入的 ...

  6. [51nod1515]明辨是非

    Description 给$n$组操作,每组操作形式为$x\;y\;p$. 当$p=1$时,如果第$x$变量和第$y$个变量可以相等,则输出$YES$,并限制他们相等;否则输出$NO$,并忽略此次操作 ...

  7. codevs1091 传染病控制

    题目描述 Description [问题背景] 近来,一种新的传染病肆虐全球.蓬莱国也发现了零星感染者,为防止该病在蓬莱国大范围流行,该国政府决定不惜一切代价控制传染病的蔓延.不幸的是,由于人们尚未完 ...

  8. 小米手机(HM1SW)高通开发android程序全过程

    小米手机(HM1SW)开发android程序全过程 修改历史: 2016年5月9日  --------  整理文档 a.增加了手机基本信息. b.增加360手机助手连接说明 2016年2月26日  - ...

  9. string字符串的一系列操作

    IndexOf() 查找字串中指定字符或字串首次出现的位置,返首索引值,如: str1.IndexOf("字"): //查找“字”在str1中的索引值(位置) str1.Index ...

  10. jpa findOne()用法

    findOne(Interger id) 如果实体类没有id这个属性的话是会报错的 改别人的代码神烦...