最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

jquery ui - How to hide a Table Header using Javascript - Stack Overflow

programmeradmin2浏览0评论

How to hide table headers in javascript.

In detail am using easyui-datagrid in which i have to hide the column header.

Please guide me to fix this.

Thanks in advance.

How to hide table headers in javascript.

In detail am using easyui-datagrid in which i have to hide the column header.

Please guide me to fix this.

Thanks in advance.

Share asked Apr 16, 2013 at 7:58 BashaBasha 312 gold badges4 silver badges9 bronze badges 1
  • 1 It always helps to include some sample code in order to be able to provide you with a good answer... – excentris Commented Apr 16, 2013 at 8:08
Add a ment  | 

4 Answers 4

Reset to default 1

If you use pure javascript without the help of any framework, like jQuery etc, you should give an id to your table and assign the table object to a variable:

var tb = document.getElementById("your-table-id");

and then find the "thead" tag inside the table and hide it, as follows:

tb.getElementsByTagName("thead")[0].style.display = "none";

note that getElementsByTagName returns an array of html elements, since a valid table can have 0 or 1 "thead" occurrencies, if you are sure that your table has headers you can securely access the first element and change it's visibility.

If you really need to use JavaScript, then you should be able to use standard selectors and jQuery and use the Hide method:

$("#id or .class of header row").hide();

But I'd remend using CSS instead:

#id or .class of header row {
    display: none;
}

It's lower impact using the CSS route, and all the jQuery will do it apply the same style directly to the element.

I did it with this code:

 $('#my-ddata-grid').datagrid({
 ....
 ....
 });

jQuery('.datagrid-header-inner').hide();

You can also remove other elements, like the pagination-bar like this:

jQuery('.datagrid-pager.pagination').remove();

The following code worked me :

<style>
.datagrid-header-row {
    visibility: collapse;
}
</style>
发布评论

评论列表(0)

  1. 暂无评论