# DataGrid Header Dilemma

**URL:** <https://forum.kirupa.com/t/datagrid-header-dilemma/30485>\
**Category:** flash\
**Created:** [September 9, 2003, 2:30pm UTC](https://forum.kirupa.com/t/datagrid-header-dilemma/30485 "2003-09-09T14:30:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cybjorg](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/cybjorg/32/324_2.png) [@Cybjorg](https://forum.kirupa.com/u/Cybjorg)\
**Post date:** [September 9, 2003, 2:30pm UTC](https://forum.kirupa.com/t/datagrid-header-dilemma/30485/1 "2003-09-09T14:30:50Z")

</div>

I am attempting to create a rich internet mail client and I am utilizing the FUI Components DataGrid to display the messages.

I currently have a simple preloader (frames 1-2) and three frame labels following: Inbox (frame 4), SentItems (frame 9), and DeletedItems (frame 14).

The DataGrid formatting loads on frame 3:  
[SIZE=1]  
[COLOR=silver]// Set up global style for componants[/COLOR]

globalStyleFormat.textSelected = 0x7f9db9;  
globalStyleFormat.textFont = “Verdana”;  
globalStyleFormat.header = 0xebeadb;  
globalStyleFormat.face = 0xebeadb;  
globalStyleFormat.scrollTrack = 0xcdcbb8;  
globalStyleFormat.shadow = 0xaca899;  
globalStyleFormat.highlight = 0xffffff;  
globalStyleFormat.darkshadow = 0xf1efe2;  
globalStyleFormat.highlight3d = 0x716f64;  
globalStyleFormat.gridlines = 0x716f64;  
globalStyleFormat.applyChanges();

[COLOR=silver]// Quick grid formatting[/COLOR]

messageGrid.setRowHeight(25);  
messageGrid.showBorder(true);  
messageGrid.getColumnAt(0).setWidth(150);  
messageGrid.getColumnAt(1).setWidth(380);  
messageGrid.setColumns(“From”, “Subject”, “Received”);  
messageGrid.sortItemsBy(“Received”, asc);  
[/SIZE]

As you can see, I have the DataGrid header set up into 3 columns: “From”, “Subject”, and “Received”.

Upon entering the SentItems frames, however, I would like to reformat the DataGrid so that the columns are listed as “Recipient”, “Subject”, and “Sent.”

I have created the following function to make the change:  
[SIZE=1]  
function formatSentItems() {  
messageGrid.setColumns(“To”, “Subject”, “Sent”);  
messageGrid.sortItemsBy(“Sent”, asc);  
}  
[/SIZE]

Upon the Sent Items button keypress I have set the following code to call the above listed function:  
[SIZE=1]  
btnSentItems.onPress = function() {  
gotoAndStop(“sentItems”);  
formatSentItems();  
};  
[/SIZE]

The only problem is that, rather than changing the column names, the function simply appends the columns to the DataGrid (i.e.: I now have the following columns: “From”, “Subject”, and “Received” _and_ “Recipient”, “Subject”, and “Sent”.

Does anyone know what I am doing wrong?
