UITableViewController indexPathForSelectedRow returns incorrect value - didselectrowatindexpath

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.

Related

Can tree column be hidden programmatically in TreeTableView of 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.

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/

Flex Datagrid insert row below current row

my application needs to allow users to insert rows below the current datagrid row. My solution is to to add a row to the dataproviders collection. This works, but the row does not appear beneath the current row the user clicked on.
The Datagrid has a default sort order (date ASC), which re-orders the data...so this seems to affect the position of the row in the grid.
Any ideas how to fix this?
Two possible answers:
1. define your own sort function that sorts according to item order in dataprovider (i.e. it does nothing), and assign it to the sortFunction property
2. simply comment out the sorting of the data inside the component.

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