Can tree column be hidden programmatically in TreeTableView of JavaFX? - javafx

I have a useful TreeTableView GUI view definition builder and would like to use in on tabular data where I don't need drill downs. I tried ...
m_treeTableView.getTreeColumn().setVisible(false);
... but it doesn't hide the tree column. Any help?

getTreeColumn appears to be returning null regardless of the thread or delayed execution I call it from. However, the column exists at index zero in the TreeTableView vector of columns. Hiding it by index works fine but gives unpredictable results if drill-down is defined.
However, TreeTableView hides the column automatically and elegantly if no drill-down is defined - logical behaviour and exactly what I need.
Edit: getTreeColumn returns null even if the column is not null, but is at its default position, leftmost place. Otherwise it returns the column.

Related

javafx treetableview cell value not getting updated

Event after updating the data model javafx treetableview cell value not getting updated.
I am using the sample code here # http://docs.oracle.com/javase/8/javafx/user-interface-tutorial/tree-table-view.htm
(Example 15-2)
On click of button i m trying to update first item: employees.get(0).setName("Test");
Is there any trick using which treetableview can be updated?
The example, somewhat strangely, returns a ReadOnlyStringWrapper wrapping the property values for the cell value factories. Thus instead of binding the value displayed in the column directly to the properties in the Employee class, it binds them to a new, read-only, property wrapping the value retrieved when updateItem(..) is called on the cell. This means it won't get updated when the underlying data is updated, but only if the updateItem(...) method is invoked on the cell. (I have no idea why they would do this.) So you should find, for example, that if you change the value, then collapse the root node in the TreeTableView and expand it again, that your new value is displayed after expanding the root (because this causes the cells' updateItem(...) methods to be invoked).
To make the cells update when the data is changed, bind the cell value directly to the property defined in the model (Employee) class:
empColumn.setCellValueFactory( param -> param.getValue().getValue().nameProperty());
and
emailColumn.setCellValueFactory( param -> param.getValue().getValue().emailProperty());

Dojo Datagrid open first cell of new item for editing

I am trying to use doStartEdit(inCell, inRowIndex) function of datagrid to open first cell of newly added row for editing in dojo 1.9 Enhanced grid, but the function does not work.
It says in api that the arguments should be:
inCell - object of a cell (I get it with getCell() function)
inRowIndex - index number of a row
I am not sure because arguments are not clearly described in the api, I tried to look at the same variable descriptions near other grid functions.
I tried other variations of arguments, like cell number insted of object, and row object instead of row index. None of them worked. Is it a bug? Or I just use it in wrong way?
If you are looking to do is focus and set a cell for editing by the user then below should work for you.. that will focus on column 1 row 1.
grid.edit.setEditCell(grid.getCell(0),0)
Fiddle:http://jsfiddle.net/Pjzef/

Qt error "persistent model indexes corrupted" why?

I've a problem with my Qt/interview application. I use QTreeView to display tree data. I implemented my own model based on QAbstractItemModel.
I get a following error prior to application crash. It happens often after I add new record.
Could You explain to me what is the meaning of this error. What is a QPersistentModelIndex ?
I'm not using QPersistentModelIndex in my code.
ASSERT failure in QPersistentModelIndex::~QPersistentModelIndex: "persistent model indexes corrupted"
Thanks.
QPersistentModelIndexes are (row, column, parent) references to items that are automatically updated when the referenced items are moved inside the model, unlike regular QModelIndex. For instance, if you insert one row, all existing persistent indexes positioned below the insertion point will have their row property incremented by one.
You may not use them directly, but QTreeView does, to keep track of expanded items and selected items, for example.
And for these persistent indexes to be updated, you have to call the functions QAbstractitemModel::beginInsertRows() and endInsertRows() around the actual row insertion(s) when you add new records.
See the end of the section about subclassing model classes for details: http://doc.trolltech.com/latest/qabstractitemmodel.html#subclassing
I found this method QAbstractItemModel::persistentIndexList and I'm
wondering what indexes it should return. All of them ?
Should this method return all nodes currently visible in the TreeView ?
That method returns only the indexes for which a QPersistentIndexModel was created and is still in scope (as a local variable, a class member, or in a QList<QPersistentIndexModel> for example).
Expanded or selected nodes are not necessarily currently visible, so you can't (and shouldn't anyway) assume anything about what these persistent indexes are used for.
You just have to keep them updated, and you only need to use persistentIndexList for big changes in the model, like sorting (see QTreeWidget internal model : QTreeModel::ensureSorted(link)), for smaller incremental changes you have all the beginXxxRows/beginXxxColumns and endXxxRows/endXxxColumns methods.

UITableViewController indexPathForSelectedRow returns incorrect value

I'm not sure what is going on but I have a list that has 3 items and I am selecting row 1.
I am using a viewcontroller that is a UITableViewController and that has a property tableView where I am accessing the indexPathForSelectedRow during the didSelectRowAtIndexPath.
For some reason this value is incorrect sometimes...
What could cause this?
The UITableView * param on didSelectRowAtIndexPath is also called tableView.
If your table has more than one section that can confuse things (it's caught me before). indexpath.row will return the row number in the section of the table, not the row number of the overall table. If that's not what you're expecting it'll appear wrong.

How to get proper row index values of grid view after sorting

I have an asp.net application in which I am using a grid view. Paging and sorting are applied to the grid view. One action what I am doing is on click of any grid view row, am getting the column values of the selected row and redirecting to the other page.
The problem is after the grid view is sorted, if I click on any of the row in ayy page (paging index), am getting only first page values even though the visible row is different.
I am getting the row values in gridview_rowcreated() method and putting in some variable. In sorting scenario, before sorting is done, the gridview_rowcreated() method is called but not after the sorting is done.
In case you still need an answer to this...
You should be using the gridview's SelectedIndexChanging event with something like the following:
gridView.Rows.Item(intNewIndex).Cells(# of column, zero-based).Text
This will give each cell's current value, you'll just have to loop through each cell and assign each cell's value to desired variable(s).
Hope this helps!!!

Resources