Java FX 8 Tablecell data to Listview selected data - javafx

I have a Java FX TableView with a column. This column is pre-populated with values from a database. When I click a cell on the table a listview is shown, I can update the table cell and the DB by selecting the values from the list.
Before the listview shows up, I set the selected value of the list to match the existing table cell's value by the following
listView.getSelectionModel().select(this.getItem());
when the list view opens the selected item corresponds to the cell value of the table.
I have a onchangelistener attached to the listview's selectedItemProperty.
From this list view if I choose a new value, When the selection changes the DB gets updated and the table cell gets updated with the new value.
If there is a problem with the database update, the listview's selected ItemProperty still retains the newly selected value.
I have tried resetting it using
listView.getSelectionModel().select(this.getItem());
but this doesn't reset the selectedItemProperty value.
Hence if you click the same cell once again, the list is having the previously selected value highlighted (i.e the value which was not updated due to a DB failure) the table cell and the selected value in the listview are different.
How do I overcome this ?

Related

How to distinguish selected row from current row in TableView in JavaFX?

If display simple TableView sample, then select first row, then press Ctrl and then Down Arrow button two times, we will see the following picture:
I.e. first row remains selected, while third row get cursor.
How to know this row?
This is the focused row. You can access that row via the focusModel property:
int rowIndex = tableView.getFocusModel().getFocusedIndex();
The TableView.TableViewFocusModel class used for focusModel also supports some additional features like accessing the item for the focused row.

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());

getting first index value from dropdown list

I need to display the grid View populated with some data on selected index change event of a Drop Down List .
It will be fine when selecting other index values from the drop down list at first time.
but when selecting first index value at first time ,the selected value returns nothing.
how to get the selected value from the drop down list on first click.
Don't set SelectedValue or SelectedIndex while populating/binding the DropDownList.

How to persist an ASP:Table with TextBoxes inside cells?

I have an ASP.Table whose cells are containing textboxes filled by the user.
When he clicks on a button, I want to store textboxes content into a database but in the onclick event, the table is empty. How can I persist the whole table, and especially the textboxes data ?
Create a name value collection corresponding to the columns and rows of the table. Store each cell value as a part of the name value collection in the DB with the name in the form of r1c1, r1c2, etc.

DevExpress RowUpdating old values returning text value

I have a DevExpress ASPXGridView which has been bound with a dataset.
I'm using the edit row command to edit the data in the row and return it to the database.
When the edit button is clicked, the row opens up and there is an ASPXComboBox that is bound to another dataset. The TextField and the ValueField have both been properly set in the ASPXComboBox and are displaying data correctly. The data is as shown
List item
List item
When e.NewValues("") is called the integer value field i.e 1 is returned. However, when e.OldValues("") the TextField is returned i.e. "List Item"
Is there a way of returning the the integer value when calling e.Oldvalues without having to make another call to the database?
Thanks

Resources