I am trying to turn the header on and off in a grid, depending on if it has records or not.
It appears if I set showHeader to false when I create the grid I can never set that to true and have it display.
However if I set it to true when creating the grid and then call _setOption('showHeader', false); It will hide but since this is a private method I was wondering the correct way to accomplish this.
Hello,
Thank you for the details provided. You can use below line to set header visibility to false using public API:
$("#grid1").igGrid("option", "showHeader", false);
Refer to the “OPTIONS” tab and look for showHeader on the link below:
http://help.infragistics.com/jQuery/2012.2/ui.iggrid
If showHeader is false while initializing grid than the Header table is not created at all. I have also logged this behavior with development 135743. I will update this forum thread once this issue is resolved or if I have heard anything from development.
Meanwhile, I would recommend you to set showHeader to false in the igloader function and show header when you need it as shown below:
$("#grid1").igGrid({
autoGenerateColumns:true, primaryKey:"ProductID",
columns: [ { headerText: "Product ID",key: "ProductID",dataType: "number"},
{ headerText: "Name",key: "Name", dataType: "string"},
{ headerText: "ID",key: "ID", dataType: "number" },
{ headerText: "ProductDate", key: "ProductDate", dataType: "date" }, ],
dataSource:products,
});
$("#button1").click(function()
{
$("#grid1").igGrid("option", "showHeader", true);
I hope this helps.
Setting it to false to soon creates issues with rendering, especially if you show or hide columns, I hooked into the iggridheaderrendered event and setting it to false after that seems to work fine, anything before is asking for trouble.