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 )
Related
I am using Vaadin 14 grid. This grid contains a number of columns. A few of them need to represent boolean values, hence we use a checkbox component inside that column. This is done by using grid.addComponentColumn method. The text related columns a just added using grid.addColumn
Now we want to enable multisort on the grid. By default the sorting indicators (up/down arrow) in the header are shown for the text based columns but not for the boolean values .
After adding sorting to the boolean column /component column (addComponentColumn(...).setSortable(true) the sorting indicators in the headers are shown, but the sorting itself is not performed when changing the sort direction (none / asc / desc) using the arrows in the header.
How can I make this work?
Thanks in advance!
When you have custom logic for what's rendering in a column, then you also need to explicitly configure how sorting should be handled for that column.
If you're using in-memory data, then you do that using Column.setComparator. If you're using a backend data source, then you should instead use Column.setSortProperty and also ensure that the data provider actually considers the contents of Query.getSortOrders.
You can see an example of this in practice at https://cookbook.vaadin.com/sort-with-renderer.
I'm trying to implement multiple record selection feature on a grid.
It is very similar to http://www.tek-tips.com/faqs.cfm?fid=3831
It adds an extra column with check boxes. I want those check boxes!!
But it depends on a extra logical field in the underlying table. It need to create a class clscheck which inherits CHECKBOX. I'm not sure why this CLICK procedure is needed for the checkbox.
PROCEDURE CLICK
IF DODEFAULT()
KEYBOARD '{DNARROW}'
ENDIF
ENDPROC
When I removed it, row selection did not work correctly as expected. Why this?
Here is my requirement:
1) I don't want to add an extra logical field in the underlying table.
2) To work with controls in the grid, I think AllowCellSelection must be .T. I want AllowCellSelection = .F. because I don't need to work with any control in the grid except the check boxes. I need to work only with check boxes. The other columns will be read-only.
3) Can I have selected list without the logical field in the underlying table?
4) Can I remove the usage of KEYBOARD '{DNARROW}'?
In fact, I have a grid which is AllowCellSelection = .F., but it only provides single selection.
I need to enhance it with multiple selection, thus, I just want to add an extra column with check boxes so that user can know he can select multiple records.
No need Shift+Click or Ctrl+Click which is not familiar with idiot users.
I have found this - http://www.tek-tips.com/faqs.cfm?fid=433
It also depends on an extra logical field and it depends Shift+Click and Ctrl+Click.
What you are seeing is quite common for multi-select grids. I've used them SIMILAR to this in the past. However, you are afraid of the extra column in the underlying table. That may/not be true. You don't always have to update the ORIGINAL table, but a temporary CURSOR you are presenting to the user. Ex: If you want to display a list of employees in a table. No, you don't want to keep adding this column to the original employee table as then anyone else trying to do multi-select could falsely get your selection. However, if you pulled into your own local cursor and presented to the user, then no problem. Example...
Thisform.YourGrid.RecordSource = "Employees"
(bound directly to your employee table -- not necessarily the right thing)
vs
use in select( "C_MultiPickEmployees" )
select ;
.F. as IsChosen, ;
E.* ;
from ;
Employees E;
into ;
cursor C_MultiPickEmployees READWRITE
Thisform.YourGrid.RecordSource = "C_MultiPickEmployees"
NOW, you have your extra column without dealing with issues to the underlying table. If you wanted to further filter what you were showing -- such as employees for a certain division/department, then just add that to a WHERE clause, add an Order By if so needed and you are good to go.
As for the "Allow Cell Selection", I've never had to deal with that. I just add a "checkbox" to the first column and set
Thisform.YourGrid.Column[1].CurrentControl = "CheckBoxControl"
(based on the name it is added to the column).
Then, set the column 1's "ControlSource" = "C_MultiPickEmployees.IsChosen" and you should mostly be done.
As for the "CLICK" event trying to force the down arrow. This is more for automatically scrolling to the next record so you can just click, click, click for multiple entries.
Hope this helps clarify things for you.
Hello
I want to show nodes to the columns, depending on their term.
Is it possible via single view (term with depth arg)?
It will be rather complicated to achieve this result using a single view. On the other hand, you could easily set up Panels and a view pane that gets some arguments from the pane's column container. There you could set the different terms you want to show in that column.
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.
I've got very dynamic GridView and I need to allow to user to edit first column of it. After he edit first column of grid it must be updated on DataBase.
Is there any ways to handle it ?
My only idea is to put some changeable element to first cell of each Row so it must be able to set / get my values for each row but can't find yet any examples of it ...
Additional info :
GridView takes data from Object data source and all columns are dynamic (yes, maybe except first, but I add it in dynamic way) and load complete DataTable... \
Currently Using jQuery+Ajax methode on dynamic button but can't disable button's PostBack so with a PostBack it just disappears and dont make the event it must to make...
Since you have dymanic columns, for each column, specify the read-only property (If a column is read-only, it may only be looked at, and not edited when in the GridView's Edit-Mode).
So, the first column of would be readonly="false" (or omit it entirely) and the other columns read-only="true".