Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > Flex > Flex 2, 3 & 4

Reply
 
Thread Tools Rate Thread Display Modes
Old 04-03-2009, 03:28 AM   #1
Pratap
Pratap
 
Pratap's Avatar
 
Join Date: Jul 2006
Location: Hyderabad
Posts: 62
Send a message via Skype™ to Pratap
Question How to draw border for selected row in datagrid?

Hi,

Any idea how to draw border to selected row in datagrid??
only to selected row.

Thanks & Regards
Pratap
Pratap is offline   Reply With Quote
Old 04-07-2009, 10:07 AM   #2
Pratap
Pratap
 
Pratap's Avatar
 
Join Date: Jul 2006
Location: Hyderabad
Posts: 62
Send a message via Skype™ to Pratap
Default

no result till now :-(((((((
Pratap is offline   Reply With Quote
Old 04-07-2009, 05:46 PM   #3
JeTSpice
Senior Member
 
Join Date: Apr 2009
Posts: 114
Default

You need to extend the item renderer to draw each cell. (I have such an extension if you need it)

However, it will draw to each cell in the row, so every cell will have a border. I didn't pursue it any further than that, but just drew a solid line at the top and bottom of each cell. It "looks" like there is a border around the row, but there are no sides to the border, only a top and bottom.
JeTSpice is offline   Reply With Quote
Old 09-11-2009, 10:13 PM   #4
tpang
Registered User
 
Join Date: Sep 2009
Posts: 1
Default

Hi, I'm dealing with the same problem....Instead of trying to highlight the selected row a different color, I want to just highlight it - so basically draw a border all around it. Can you please post your solution??
tpang is offline   Reply With Quote
Old 09-12-2009, 08:48 AM   #5
flexexplorer
Registered User
 
Join Date: Aug 2009
Posts: 27
Default

tpang, you can highlight a particular cell by doing this:
1. Turn off all highlighting, like mouse over and mouse click. You can find how to
do this with google.
2. Listen for a mouse click event on a DataGrid.
3. Find the row and column value selected.
4. Look at DataGrid's listItems protected Array, which holds current item renderers.
Retrieve the item renderer using the row and column values from previous step,
and set the item renderer's opaqueBackground value to whatever you want the
highlight color to be.

This is not the most reusable solution, because it only works for DataGridItemRenderer item renderer.

Pratap, I would probably create my own itemRenderer,and listen for mouse click events, using which you'd draw a border around the item renderer. The only problem is getting the item renderer's width and height values. You can try using the item renderer's width and height values, but I don't that will work either. Try experimenting with different measurement values that are available.
flexexplorer is offline   Reply With Quote
Old 09-12-2009, 03:51 PM   #6
JeTSpice
Senior Member
 
Join Date: Apr 2009
Posts: 114
Default

oy, i spoke too soon. the "styleFunction" property is only for advancedDataGrid. apologies.
JeTSpice is offline   Reply With Quote
Old 09-12-2009, 09:09 PM   #7
Peter Cowling
quantum tunneler
 
Join Date: Sep 2008
Location: London, UK
Posts: 882
Default

A completely untested sketch, to be used as an itemrenderer to highlight individual cells:

ActionScript Code:
package {     import mx.controls.Label;     import mx.controls.dataGridClasses.*;     import mx.controls.DataGrid;     import flash.display.Graphics;     import mx.styles.StyleManager;     [Style(name="backgroundColor", type="uint", format="Color", inherit="no")]         public class BackgroundComp extends Label {     override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void     {          super.updateDisplayList(unscaledWidth, unscaledHeight);                      var g:Graphics = graphics;          g.clear();          var grid1:DataGrid = DataGrid(DataGridListData(listData).owner);                       if (grid1.isItemSelected(data) || grid1.isItemHighlighted(data){              g.beginFill(0xFF0000);              g.drawRect(-2, -2, 1, 1);              g.endFill();          }     }     } }

Last edited by Peter Cowling; 09-12-2009 at 10:46 PM.
Peter Cowling is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I draw a filled rectangle with no border? nfh ActionScript 2.0 17 05-05-2010 03:29 PM
Selecting DataGrid row avia_johana Components 0 11-29-2007 12:16 PM
DataGrid CellRenderer Oddities Metallikiller Components 1 03-14-2007 01:47 PM
selecting a row in a DataGrid glacts Flex 2, 3 & 4 4 12-20-2006 01:47 PM
I want to make colored datagrid row. how can I achive it? jj362 Components 1 04-21-2005 04:52 PM


All times are GMT. The time now is 02:12 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.