"freeze" one column in flex datagrid - apache-flex

I'm using a datagrid to display a column of date ranges and several columns of data. I'd like to make the first column (the date ranges) fixed; i.e. that column stays in place when the user scrolls the other columns. That way, the dates column will always be visible as the user scrolls through many data columns. I don't see a datagrid property for this; anyone have a solution? TIA

lockedColumnCount (and lockedRowCount) is more than likely what you are looking for.
http://livedocs.adobe.com/flex/3/langref/index.html
The reason you probably didn't see it is because it is part of the DataGridBase and not part of the DataGrid class itself.

use locked column count property
lockedColumnCount=”1″ height=”96″ horizontalScrollPolicy=”on”
verticalScrollPolicy=”on” width=”397″>

Related

Changing the tooltip dynamically for each record

In forms I have a block that contains name of tables.
The column is narrow so I want to add a tooltip that contains the value for each row.
I tried to put this code in post_query
:set_item_property('block1.value',tooltip_text, :block1.value);
but the tooltip always contains the last row's value and shows
it for all the rows. What could be the problem here?
set_item_instance_property is the ideal way to affect a column for just specific rows of data. But, tooltip_text is not available for setting via set_item_instance_property.
What you could do, though, is put your call to set_item_property into a when-new-record-instance trigger on the block. That way it should change the tooltip each time a new record becomes the focus.

How to create a grid to reconfigure grid columns on the fly

I have a grid with 10 columns, and another with over 60. I want to offer a view of these grids where any column or number of columns can be selected to remain visible. Then submit a request to hide all of the remaining 'UN-selected' grid columns, leaving the selected columns viewable.
End-users need to have a mechanism where they can choose which column(s) to view and the remaining columns will be hidden temporarily from view. I know that I can choose each column from the context menu to hide each column, but if I have a grid with multiple columns it can be quite difficult to select each column to hide. I would like to create a mechanism where users can select which columns they want to 'view' and allow the remaining columns to hide.
I believe that grid reconfigure may be the way to go, but there are no real examples showing how I might select the columns to allow viewable "on-the-fly", and then reconfigure the grid based on the new column model.
There are a couple of ways you could approach this:
One way would be to loop through the columns and call hide() method on those you wish to hide.
For a large number of columns it might be better to use reconfigure method. using reconfigure with the first paremeter undefined you get to reuse the store that was originally configured:
reconfigure( undefined, myColumns )

Flex 4 How do I access a specific cell by index?

I would like to edit a cell by the row and column indexes so essentially do the following:
advDataGrid[2][3] = "Dogs"
so that I am setting the data grid row 2 and column 3 to Dogs. I cannot for the life of me figure out how to do this!
Side note: I need this because I am trying to allow the user to copy a section of an excel file to a section of an AdvancedDataGrid like Google Docs does. I am using this idea to do it: http://mannu.livejournal.com/348299.html
Thanks! Any help will be greatly appreciated!
In general you want to operate on the dataProvider rather than the presentation (AdvancedDataGrid). So in your case, I would get the item associated with the specified row from your dataProvider and modify whichever element is specified to "Dogs". So something like this: adg.dataProvider[row].someColumnData = "Dogs"
EDIT: "someColumnData" refers to whatever property you have set for the column to display. So when you defined your AdvancedDataGrid's columns, you set the 4th column to use the "someColumnData" property of the items in your dataProvider, and you want to change the value in the 4th column, then you'd set it as described above. Hope that clarifies things.
Flex components are data driven, so you should modify the data provider of the grid.
What if you want to edit specific individual cells, eg I want to to keep running totals of some cells in other cells, IE: as a user edits I update whole columns.
Surely their must be a way to walk the array and get Column4.row6 = something.

Flex dataGrid how to color empty rows?

My problem is that empty rows (if there are more rows that dataSource items then there are empty rows) look identical to rows binded to dataSource items which are empty (see the difference?).
The only way to know the difference is to hover over them with the mouse, and if they are empty there's no color change, otherwise there's the blue background of the selection..
I want to change the color or in some way hide empty rows, those that are not bound to a dataSource item.
How can I accomplish this?
You can format your DataGrid using ItemRenderer.
The itemRenderer is a display object that get the data from the data provider and display it in the grid.
Writing your own logic can help your specific data display in general. in this case, check for data on the ItemRenderer object creationComplete. it the data is null or empty - display a sign (or whatever).
See this link as reference:
http://blog.flexexamples.com/2007/08/20/formatting-a-flex-datagrid-control-using-a-custom-item-renderer/
Enjoy!
I'm not sure if this is exactly what you are looking for but I cut off my rows at the end of my dataprovider like this:
myGrid.rowCount = myDP.length();
This can of course be modified with some simple logic to have min, max, or if it's a data entry type of grid length()+1.

ASP.NET Datagrid - hiding a specific row/column

I am using a Datagrid with several columns of data (call it myDG) and one of these columns is a DateTime bound to a datasource. Its value is dependent on a "job" object completing a job and assigning the date time value. Since this normally takes up to a minute the value is left unassigned at the beginning.
The column's asp.net definition is:
<asp:boundcolumn
DataField="CompletedDate"
HeaderText="Date Completed"
DataFormatString="{0:dd-MMM-yyyy <br> hh:mm:ss tt}" />
So the functionality works fine when the "job" has completed and it sets the time. But before that, while the row is being displayed, it shows as
01-Jan-0001
12:00:00 AM
I am wanting to hide this and determined that the best way would be to mask that particular row and column with a blank, or override the value temporarily. I am having problems doing this and finding a way to access that specific row and column.
It is the [3] column of the datagrid and always in the first row (since new rows are added at the top).
Is there a way to directly access this cell and temporarily 'hide' its contents, or mask them? Ideally it would be great if there was a way to blank out all rows that had a value equal to this in their column, but a way to manipulate the specific cell would work as well.
-thanks in advance!
I would probably hook OnItemDataBound, check the value, and replace/reformat if required.
I asked a similar question about hiding columns here.
I had to use the RowCreated event to hide certain columns from the user (PK columns) and this may help you out as well (especially with hiding databound columns).
I have done similar things in the past and here is what I have done.
Bind the data to a column that is not visible at all. Add a visible column for the data you wish to display. At the time you populate your grid, loop through the records and for any that have a value that isn't 01-Jan-0001 12:00:00 AM, set your visible row to that value. If it does equal 01-Jan-0001 12:00:00 AM, then set the value of your visible row to an empty string or some value of your choice. (You could even set the text color to the same as the background color so it wouldn't appear to the user)

Resources