In Vaadin 8.1, the Grid API doc shows that we can pass a renderer as part of the column definition when calling addColumn. But I do not see any setter methods for changing the renderer.
Is there any way to change the renderer on a column in the Grid object?
Column rather than Grid
Call setRenderer on the column rather than the grid.
The column is represented by a class nested inside the grid class, Grid.Column. Pass a column ID to retrieve the particular column.
myGrid.getColumn( someColumnId )
There you call setRenderer.
myGrid.getColumn( someColumnId ).setRenderer( myRenderer ) ;
Replacing the renderer is shown in the Vaadin Framework guide, Grid page, section Column Renderers.
Related
I was wondering what the difference between data and listData in itemRenderers in flex. I have worked with data in all of my itemRenderers.
Basically I want to know when to use which, where each gets set and if I can use them together?
Note that I am asking from a Flex3 point of view.
data is the data that the renderer should display. Use it to work with the original data currently assigned to the renderer.
listData is an additional object to provide you with information about the role of the renderer in the list (rowIndex, columnIndex, list component, uid, ...). Use it to perform some UI related operations such as formatting the first row differently or rows alternating depending on their vertical index, calling the list view component, etc.
Each item of your dataProvider collection is passed to data variable. You entirely define, what is passed to data by defining dataProvider content.
Information about the cell of datagrid/list (such as row/column index, label) is passed to listData (see BaseListData). To use this variable your itemrenderer should implement IDropInListItemRenderer interface.
See details about listData here. The main point is:
The list classes will pass more information to the renderer so that it
can determine which field to use at run-time.
So listData is for advanced usage for more complicated item renderers.
See this:
http://livedocs.adobe.com/flex/3/html/help.html?content=cellrenderer_4.html
And this:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/controls/listClasses/IDropInListItemRenderer.html
I am trying to build a 6x6 grid layout. In each cell, there will be an input check box. I want to bind the checkboxes to my backing bean in a "consecutive fashion"...meaning, I would like to be able to iterate over the checkboxes to see whether they are checked or not. Basically, there must be an underlying data model. For example, you can drag over and drop off as a table, any item in the data control palette. Then in my application module, I can modify the view object as I wish before I save to the database. Now if I have a table with 36 rows and two columns (one is Id, one is Numeric (1 or 0)). I would like to drag over that table and drop off as a Grid that will enable a user to update each of the rows by selecting or 'un-selecting' a checkbox.
Try to use for each or Iterator component. They iterate over some array/collection and repeat elements enclosed within those components. You can check how Oracle does Dynamic Table (when you drag view object instance from application module to a page, choose dynamic table option) to get and idea.
try :
http://jobinesh.blogspot.com/2010/06/model-driven-approach-for-building.html
http://blogs.oracle.com/shay/2010/10/adf_faces_dynamic_tags_-_for_a.html
also try google with "dynamic form adf"
From what I've seen, the formatter function in Dojo DataGrid is given the following arguments: cell value, cell row number, and the cell object itself. Can you suggest how to obtain data store item to which this cell refers, given these arguments? Or if you can suggest an alternative way, I'd be grateful.
Found it. The grid has a method called getItem(), which accepts row number as argument.
I have a flex datagrid with 4 columns.I have a comboBox with 4 checkboxes,containing the column names of datagrid as its label.I want the datagrid to display only those columns which are selected in combobox.Can anyone tell me how this filtering of columns in datagrid can be done?
Thanks in advance.
You can manipulate the columns attached to the data grid using the .columns property. Bear in mind that this method is a getter and returns you a copy of the list of columns on the datagrid, so if you manipulate its contents you have to apply those changes back to the data grid using the equivalent setter, e.g.
<mx:DataGrid id="dg" />
in ActionScript code
var columns:Array = dg.column;
columns.push(new DataGridColumn("hello"));
dg.columns = columns;
In your case you could hold your master list of columns in a separate array and push them onto the data grid as the user checks and un-checks them from the list in your comboBox.
Alternatively you can iterate through the column list looking for the ones which are checked in your comboBox and set their .visible property accordingly.
HTH
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.