JavaFX: Handle ComboBox selection event which is inside the TableView Column - javafx

I have a javafx TableView and I want custom controls inside the columns. Say I want a TextField in column1 and ComboBox in column2 and DatePicker in column3.
I know that I should create a class that extends TableCell and override the updateItem() method....
But I read that specifically for this purpose we have default classes like ComboBoxTableCell, TextFieldTableCell etc in the cell package and it is recommended to use them. So I'm able to achieve this with the below code.
loadingStatusTableColumn.setCellFactory(ComboBoxTableCell.forTableColumn("Off", "Load All", "Load By Time"));
startTimeTableColumn.setCellFactory(TextFieldTableCell.forTableColumn(null));
stopTimeTableColumn.setCellFactory(TextFieldTableCell.forTableColumn(null));
Now my requirement is when I select some value from the loadingStatusTableColumn combobox (Say "Off"), I want to disable the next 2 columns startTimeTableColumn, stopTimeTableColumn and they should be enable when I select any value other than "Off" in the loadingStatusTableColumn column.
How to achieve this with my above code(without creating TableCell subclass).
Can i achieve the below line effect through FXML?
loadingStatusTableColumn.setCellFactory(ComboBoxTableCell.forTableColumn("Off", "Load All", "Load By Time"));
<cellFactory><MyCellFactory /></cellValueFactory>
I know the above works because it is a custom class I have, but can I do the below?
<cellFactory><ComboBoxTableCell /></cellValueFactory>
Thanks in Advance!

Related

How do I make RadioButton and TextField disappear?

Hi l want to make RadioButton and TextField disappear After the user completes the required data so that he or she will replace it as a result of the test
You can use the setVisible(boolean) methods on an Node to hide your elements. Your code would look like this, assuming your radio button is named radioButton and your text field textField, respectively.
radioButton.setVisible(false);
textField.setVisible(false);

How to get the tableview object which is inside a tab which inturn is inside a Tabpane Javafx

I have a tabpane which has 13 tabs and each of those thirteen tabs have 13 table views as well as some components like buttons and labels in each tab
I want to get the tableview object by selecting the tableview from a particular tab.
Like if the focus comes to a table view i can get to know from which tab it has come so that i can use the particular tableview object in a method.
As i have a method that will do a task which is same just the tableview changes depending upon the tab , si if i can get the tableviews i do not need to code 13 methods. But the issue is the tab on tabpane dosent only have tableview it has labels buttons also. How to fetch the extact I am not sure how to move further as beacuse what i exactly want is like i have a method that will do a task which ia same just the tableview changes depending upon the tab , so if i can get the tableview obj of each tab i do not need to code 13 methods. But the issue is the tab on tabpane dosent only have tableview it has labels buttons also. How to fetch the extact node.
The logic behind the tab and tab pane is a fxml component . I am using fxml component to develop my application.
eg:-
Set<Report> selection = new HashSet<Report>(businessEventReport.getSelectionModel().getSelectedItems());
here the businessEventreport is a table view in a table , i want to get the particular tableview by focusing on the particular tableview of the tab.
how do i do that .
i can get the tabs using
SingleSelectionModel<Tab> selectionModel = tabpane.getSelectionModel();
selectionModel.getSelectedItem().getContent();
but i am stuck after that.
One solution would be to assign each of your TableViews an identifier. This
identifier would then be used to discover the TableView from amongst the set of controls on each tab (or the whole Scene) using the lookup method.
To set the identifier for each TableView use the Node.setId method.
tableView.setId("MyTable")
To find the TableView from the TabPane use the Node.lookup method.
Tab selectedTab = tabPane.getSelectionModel().getSelectedItem()
Node selectedContent = selectedTab.getContent()
TableView selectedTable = selectedContent.lookup("#MyTable")
The lookup method searches through the children of the Node used to perform the lookup. This gives you the flexibility to either assign each of your TableViews a unique identifier, allowing lookup from TabPane itself or to assign them all the same identifier and use the parent Tab to discover the TableView (example above).
The lookup method uses a CSS selector to find controls so identifiers aren't mandatory. An alternative approach would be to use the class type and state of the TabPane and TableView to form a selector. Something like the following (untested).
selectedContent.lookup(".tab-pane > .tab:selected > .table-view")

JavaFX TableView how to get a row cell graphic

I have a JavaFX TableView, the first column is a selection checkbox column, user can select the checkbox and do something. And in the header column, it have a checkbox, I wan't it to be select all, when selected this column, it will select all checkbox to be selected. But the question is I haven't found there have any methods or ways in the JavaFX TableView or TableColumn to get the checkbox in the table row. If I can the checkboxs in the table row, I can change their state to checked.
Thanks in advance.

Datagrid Flex 3 Single Row Selected

I have one flex datagrid which contains number of rows and column. I want to make selected row editable by clicking on edit button. Is it possible? I have try many samples but on that either entire datagrid is editable or particular row's single column is editable. Is there any way to make selected row editable by clicking on edit button?
You can get the selected row with the grid.selectedIndex property. One thought to you problem:
Add an "editable" property to you items in the datagrid which is false by default
When clicking on the button, set grid.selectedItem.editable = true;
Change the grid's item renderer to a new one, which displays TextInput fields if an item is editable or just plain Label if it's not
You can change the item renderer at runtime like this:
grid.itemRenderer = new ClassFactory(com.myapp.renderers.MyGridItemRenderer);

How to identify changed row in editable grid in LightSwitch (C#)

I have an editable grid for invoices and a few checkbox columns like invoice, sent to customer / ok to invoice. I have fields updated by/updated on for these boolean fields.
I want to update these two columns if checkbox values have been changed. I am not sure how can I do this. Any help?
The way that I do this is by implementing the INotifyPropertyChanged interface for the SelectedItem property of the DataGrid. Perfect for "I want to update these two columns if checkbox values have been changed".
If you need code just let me know.
In the screen designer for the page select the property from the query (on the left) that represents the checkbox. Then click the drop down next to the "write code" link and implement the method for xxx_Changed.
Here you can then set values for your other fields based on this input.

Resources