Currently, I have a grid with default columns visible with their default width. I need to programmatically set certain columns visible and set their width. Once I set the column visible by using 'showColumn' option, I cannot reset the width of that column since the hidden attribute of the column still shows true. I am using .igGridResizing('resize',...) option to reset the width. The resizing feature has been enabled for the grid
Please let me know if you have tried my suggestions and if you have further questions regarding this!
Hello Krishna,
Thank you for posting in the community!
I suggest you are using the igGridHiding feature as well as igGridResizing.
I will assume you are using both and you want to prevent the user from resizing the columns.
Regarding column resizing, you could enable the resizing and set the handleTreshold: 0 if you want to disable the user to manipulate the igGrid column width.
http://help.infragistics.com/jQuery/2014.1/ui.iggridresizing#options
Regarding Hiding a Column you could also use both - either select it by key or by index:
$(".selector").igGrid("hideColumn", 1);
$(".selector").igGrid("hideColumn", "ProductID");
http://help.infragistics.com/jQuery/2014.1/ui.iggridhiding#methods
Showing a column like:
$(".selector ").igGridHiding("showColumn", 1);
$(".selector ").igGrid("showColumn", "Name")
You could set a column width by either select it by key or by index. You could use either:
$(".selector ").igGridResizing("resize", "Name", 300);
$(".selector ").igGridResizing("resize", 1, 300);
http://help.infragistics.com/jQuery/2014.1/ui.iggridresizing#methods
Please notice, that if you don’t want to allow hiding for the visible columns, you could set both allowHiding and hidden to false. I recommend you reading the article below
http://help.infragistics.com/Doc/jQuery/2013.2?page=igGrid_Configure_Column_Hiding.html
You could also refer to an online Sample illustrating hiding at: http://igniteui.com/grid/column-hiding
I have created a codeSample you could refer to and debug if you want. Please refer to the options and methods used to set the width of the second column with key “Name” to 300px; (although it is set to 20% in the initialization)
Good to know:
Note: It is not recommended to specify widths for only a few columns, and have a grid width defined at the same time, this results in some columns to appear arbitrary narrow. To help alleviate this problem you can set the defaultColumnWidth grid option.
You can also specify widths for every individual column separately. If you have specified column widths, and the grid also has width defined, which happens to be less than the sum of all column widths that you have defined, a horizontal scrollbar is rendered for the grid. http://help.infragistics.com/Help/Doc/jQuery/2014.1/CLR4.0/html/igGrid_Columns_and_Layout.html