Flash 8 Datagrid Styling and Sizing

  • devilwood
  • Silver Member
  • Silver Member
  • User avatar
  • Posts: 436

Post 3+ Months Ago

I'm using Flash 8 as2.

In the past I've typically built my own datagrid because I've always needed to completely integrate the design. However, I'm now working on a project that I can use the datagrid with.

First off, I load data into the grid using an array that I loop through and just using the addItem() ... I also do a little styling.
Code: [ Select ]

// style
dataGrid_instance.setStyle("fontFamily", "Verdana");
dataGrid_instance.setStyle("fontSize", 10);
dataGrid_instance.setStyle("headerColor", "0xA6CBDD");
dataGrid_instance.setStyle("alternatingRowColors", ["0xF0F0F0", "0xFFFFFF"]);
dataGrid_instance.setStyle("rollOverColor", "0xDCEBF1");
dataGrid_instance.setStyle("selectionColor", "0xFFF97D");
dataGrid_instance.setStyle("selectionDuration", 300);

// add data
//loop
//var cnum = array[i]etc etc

dataGrid_instance.addItem({Num:cnum, Callback:thedate, Countdown:thetime, First:firstName, Last:lastName, Phone:tphone});
  1. // style
  2. dataGrid_instance.setStyle("fontFamily", "Verdana");
  3. dataGrid_instance.setStyle("fontSize", 10);
  4. dataGrid_instance.setStyle("headerColor", "0xA6CBDD");
  5. dataGrid_instance.setStyle("alternatingRowColors", ["0xF0F0F0", "0xFFFFFF"]);
  6. dataGrid_instance.setStyle("rollOverColor", "0xDCEBF1");
  7. dataGrid_instance.setStyle("selectionColor", "0xFFF97D");
  8. dataGrid_instance.setStyle("selectionDuration", 300);
  9. // add data
  10. //loop
  11. //var cnum = array[i]etc etc
  12. dataGrid_instance.addItem({Num:cnum, Callback:thedate, Countdown:thetime, First:firstName, Last:lastName, Phone:tphone});


So, I get my datagrid populated and styled, but I want to set the column widths. Well, I do the following:
Code: [ Select ]

dataGrid_instance.getColumnAt(0).width = 30;
dataGrid_instance.getColumnAt(1).width = 200;
dataGrid_instance.getColumnAt(2).width = 50;
dataGrid_instance.getColumnAt(3).width = 150;
dataGrid_instance.getColumnAt(4).width = 200;
dataGrid_instance.getColumnAt(5).width = 100
  1. dataGrid_instance.getColumnAt(0).width = 30;
  2. dataGrid_instance.getColumnAt(1).width = 200;
  3. dataGrid_instance.getColumnAt(2).width = 50;
  4. dataGrid_instance.getColumnAt(3).width = 150;
  5. dataGrid_instance.getColumnAt(4).width = 200;
  6. dataGrid_instance.getColumnAt(5).width = 100



But that is not working. Actually, if I make a new test flash document and place a datagrid on the stage and place that code on a keyframe and then test with ctrl+Enter. It works. It sizes the columns accordingly. But it's not working in my published file in a browser that's actually loaded onto _level1 of another flash movie.

One odd thing is that in my published file online is if I go to another frame and then back to the frame that has the datagrid, it will size the columns correctly. ?? I think this only works going forward in frames. For instance, the datagrid and style code is on frame 2. If I go to Frame 3 and then back to Frame 2 the columns get sized. However, I can go from Frame 1 to Frame 2 and back all day long and it won't style the grid.

Is this a problem with initialization? I'm not sure how to do that. I've tried to get around this by putting the column sizing code in an onClipEvent(load) on the component but that didn't work. Thanks for any explanation on how flash handles datagrids.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • devilwood
  • Silver Member
  • Silver Member
  • User avatar
  • Posts: 436

Post 3+ Months Ago

Got it working.

The width needs to be set within the for loop that adds the data.
Code: [ Select ]

for (var i = 0; i< datanum ; i++) {
//set variables
cnum = dataarray[i];
//etc
dataGrid_instance.addItem({Num:cnum, Callback:thedate, Countdown:thetime, First:firstName, Last:lastName, Phone:tphone});

dataGrid_instance.getColumnAt(0).width = 30;
dataGrid_instance.getColumnAt(1).width = 200;
dataGrid_instance.getColumnAt(2).width = 50;
dataGrid_instance.getColumnAt(3).width = 150;
dataGrid_instance.getColumnAt(4).width = 200;
dataGrid_instance.getColumnAt(5).width = 100;

}
  1. for (var i = 0; i< datanum ; i++) {
  2. //set variables
  3. cnum = dataarray[i];
  4. //etc
  5. dataGrid_instance.addItem({Num:cnum, Callback:thedate, Countdown:thetime, First:firstName, Last:lastName, Phone:tphone});
  6. dataGrid_instance.getColumnAt(0).width = 30;
  7. dataGrid_instance.getColumnAt(1).width = 200;
  8. dataGrid_instance.getColumnAt(2).width = 50;
  9. dataGrid_instance.getColumnAt(3).width = 150;
  10. dataGrid_instance.getColumnAt(4).width = 200;
  11. dataGrid_instance.getColumnAt(5).width = 100;
  12. }

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 9 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.