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追加文件内容的三种方法

    import java.io.BufferedWriter; import java.io.File; import java.io.FileOutputStream; import java.io. ...

  2. jquery datatable(二)

    <!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> ...

  3. cufflinks install

    liuhui@pine:~/bin/cufflinks-master$ ./configure --with-bam=/usr/local/include/bam checking for a BSD ...

  4. Leetcode 200. number of Islands

    Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surro ...

  5. 【BZOJ-3343】教主的魔法 分块

    3343: 教主的魔法 Time Limit: 10 Sec  Memory Limit: 256 MBSubmit: 950  Solved: 414[Submit][Status][Discuss ...

  6. 【codevs3945】 完美拓印

    http://codevs.cn/problem/3945/ (题目链接) 题意 给出一个诡异的图形,再给出一个歪七扭八的线,问图形上下两条边与线的匹配→_→ Solution 前后求差然后KMP,这 ...

  7. vs2010 mvc3安装时报错

    今天在研究以往的商城项目时,由于前台使用的是MVC3,在没有安装MVC3的插件时,提示未能加载项目,但是在安装过程中,又提示安装失败: 决定折腾一下->居然找到一篇以前别人写的神作,特此记录一下 ...

  8. Python学习资料汇总

    官方文档:https://docs.python.org/2.7/ Python标准库:http://7xo8t2.com1.z0.glb.clouddn.com/file/Python%E6%A0% ...

  9. C# winform窗体设计-查询单个值

    查询单个值主要用于对成绩最低分,最高分,学生总数,学生性别等信息的统计 在查询单个值的时候用到了ExecuteScalar方法,连接以及语句方面,以及思路和对数据的增删改差不多 下面请看一段代码: s ...

  10. checking for tgetent()... configure: error: NOT FOUND!

    今天centos出现了下面的异常: checking for tgetent()... configure: error: NOT FOUND! You need to install a termi ...