3.2.0

Unable to add/insert a column

Hi,

My project requires addition/insertion of a column into the grid. Please let me know if there is any method available to achieve this.

I could find the methods (addRow() and deleteRow()) for a row but nothing was available for a column.

Please help!
Gaurav Arora
January 24,
There is no add/deleteColumn methods - instead you should add/remove column index from the columnIndices array and refresh the grid -

grid.setColumnIndices([...]);
grid.refresh();

http://www.activewidgets.com/aw.ui.grid/column-indices.html
Alex (ActiveWidgets)
January 24,
Hi Alex,

Thanks for the reply!

The setColumnIndices() method, as per my understanding, makes different columns (which have already been created) visible and even hides them. But as per my requirement, I need to add a column at rumtime. The number of columns is not known to me while creation of the grid. I'll start with creating some fixed number of columns, and based on user inputs, I'll keep adding more columns.
Further, I may even need to drag columns and move to new positions (like it's there for different tabs of Mozilla Firefox web browser).

I hope this explains my problem!

Gaurav Arora
Gaurav Arora
January 31,
You just need to 'clear' some Models before inserting new columns.
Please search the forum for clearxxxxxModel() for more info.
Check this sample:
HTH

<script>
var obj = new AW.UI.Grid;

obj.setCellText(function(i,j){return j + '-' + i});
obj.setHeaderText(function(i){return 'header-'+ + i});

obj.setColumnCount(4);
obj.setRowCount(5);

var Abutton = new AW.UI.Button;
Abutton.setId('lll');
Abutton.onControlClicked = function(){

var x = obj.getColumnCount();

 obj.clearScrollModel(); 
 obj.clearSelectedModel(); 
 obj.clearSortModel(); 
 obj.clearRowModel(); 

obj.setRowCount(5);
obj.setColumnCount(x + 1);

obj.refresh();
 }
 
document.write(obj);
document.write(Abutton );

</script>
Carlos
January 31,

This topic is archived.

See also:


Back to support forum