How to calculate columns in table view using a button click event handler? - event-handling

I'm trying to use a button click action to calculate the value of three columns in table view. Columns are:annualInterestRateColum, invAmountColumn , and numofYearsColumn.
The program is designed to show how much it would take to invest in another country using text fields and button clicks. I recognize I haven't set up the actual exchange rates and all of that yet.
//btCalculate.setOnAction(e -> {
//double calculate = annualInterestRateColumn + invAmountColumn + numOfYearsColumn;
//return calculateColumn.setCellValueFactory(calculate);
//});
This is my code for the event handler. I get an error message saying that "Operator '+' cannot be applied to 'javafx.scene.control.TableColumn', 'javafx.scene.control.TableColumn"
If you need the full code I can paste it here.
Here is an example of my JavaFx layout after running.

Related

Focus handling in SAPUI5

We have a requirement that of using a "tab" key in the table control to navigation across only input fields.
1. Every table row has atleast 6 to 8 fields - 2 of them are input fields and rest could be text,select etc.
2. By clicking tab i navigate across input fields in a row on clicking the last input field of a row i should move to the first input field of the next row.
I have the code for the following but i can see the focus method of the input control focuses the UI to subsequent input field of the input to be focused.
Jsbin - https://jsbin.com/lugesecuhe/edit?html,output
I tried to set styles like .sapMFocus and also document.getElementbyId().focus and they dont work either.
Can you suggest some pointers on this.
Thanks and Regards,
Veera
I have exactly the same problem and started looking into it. I found out that the navigation within the table is possible and performed by class sap.ui.core.delegate.ItemNavigation (at least in v1.26).
However, what I consider really non-intuitive:
On Mac (Chrome or Safari) you have to hold the ALT key while pressing TAB to cycle through the input fields of your table.
I haven't figured out how to do it on Windows
I checked in your JSBin example, somehow the fields get focused in a weird order. I have prepared my own example - http://jsfiddle.net/bgerth/x8h92mz8 - where you can cycle through the input fields row by row using Alt+Tab.
Update 1
I have found the blog SAPUI5 Table Navigation with Tab Key by Klaus Kronawetter which adds extra keyboard handling to a sap.ui.table.Table. I adapted his code for a sap.m.Table which you can find at http://jsfiddle.net/bgerth/os6r096y.
Update 2
After further investigation, I decided that the solution from update 1 above is too much hassle.
Instead, I adapted the class sap.ui.core.delegate.ItemNavigationmentioned above, which is internally employed by sap.m.ListBase. In essence, you can cycle through the input fields with up and down arrow keys.
I have prepared an example at http://jsfiddle.net/bgerth/0r9L30wd. The relevant code is
var fnPatchedItemNavigationsetItemDomRefs = sap.ui.core.delegate.ItemNavigation.prototype.setItemDomRefs;
sap.ui.core.delegate.ItemNavigation.prototype.setItemDomRefs = function setItemDomRefsPatched(aItemDomRefs) {
// 'this' is now the instance of sap.ui.core.delegate.ItemNavigation
jQuery.sap.log.debug("Patched version of sap.ui.core.delegate.ItemNavigation.setItemDomRefs");
var aInputFields = $(aItemDomRefs).find("input:enabled").get();
if (aInputFields[0]) {
// There is at least one enabled input field in this table
fnPatchedItemNavigationsetItemDomRefs.call(this, aInputFields);
} else {
fnPatchedItemNavigationsetItemDomRefs.call(this, aItemDomRefs);
}
}

Dynamically reload a table in a form programatically

I have a form in Dynamics AX which displays a table of two columns in a grid. I also have a button on the form. I am overriding the clicked method of the button to update the Address field of the table. For example, here's my X++ code:
void clicked()
{
AddressTable addr;
ttsBegin;
select forUpdate addr where addr.addressID == 1;
addr.Address = "new address";
addr.update();
ttsCommit;
super();
// reload table here
}
What I would like to do is to add a code to the clicked function which will reload (re-select) the updated records and show them in the form without a need of reopening the window or refreshing it using F5 (for example).
I went through forums and AX documentation and found a few methods like refresh and reread, but they are FormDataSource class methods and I failed to make it happen inside the clicked handler above.
So, what I really want to accomplish programaticallyis what F5 does behind the scenes when clicked on an open form.
Maybe just addressTable_ds.research(true); will do the job.
See also Refresh Issue on the form when the dialog closes.

how to hide and unhide authoerable tabs depending upon value selected from a drop down in CQ5

i am trying to create a footer component in CQ5, where i have 4 columns & all are autherable.
But we have to make no of columns autherable too i.e based on a value selected form a dropdown we have to open those many tabs for authoring those many columns only.
i have created a dropdown and have a maximum range of 6 columns. i know that i have to configure a listener for this purpose but don't know how . Requirement is like if i select 3 from the drop down then 3 tabs should come to author 3 columns
pls help me , i am middle of something very important.i need the solution very early too as i have to finish the job as soon as possible
I might be late for this by now but in case you still need it:
You need to add a listener node before closing your drop-down element:
<listeners
jcr:primaryType="nt:unstructured"
loadcontent="function(box){ //here you also need to handle the hide/unhide when the panel loads for the first time. Use this.getValue() to retrive the intial value }"
selectionchanged="function(box, value) {
for(var c=1;c<=value;c++){
this.findParentByType('tabpanel').unhideTabStripItem("tab"+c); // You need to handle the opposite with hideTabStripItem("tab"+c);
}
}"/>
Then on both "loadcontent" and "selectionchange" (these are events on your drop-down) grab the current selected value and use it to hide/unhide the tabs. In this case the tabs would be named "tab1", "tab2", etc, make sure you get the names right.
The ExtJS in the events is finding the "tabpanel" container for the whole dialog, and then hiding/unhiding based on name. You could also set to enable/disable using the methods ".enable()" and ".setDisabled(true)". Just make sure you get the reference to the tab first if you want to do this (something like ".getComponent(tabName).enable()").
I didn't test this specific code, I couldn't find my actual example from my code base but this should take you in the right direction.

Get Value on a Window with GridPanel using ExtJS

I have a situation here: I have a form field with trigger xtype, what I want to happen on my trigger function is to open a window with a list or grid of data in it. I want to get the value of those data and assign it as the value of my form field with trigger. Can anyone help me solve this problem. Thank you very much.
You have multiple solutions for this.
You can make use Saki's simple message bus to do the communication between extjs components.
You can create an custom event for your trigger field. When user selects a record in your window, fire the event with the selected record.
Inside your onTriggerClick :
Display your window with grid / view for user selection
Inside your Window (on some submit button):
onSubmitClick: function(){
// Get the selected record & fire event
var selected = grid.getSelectionModel().getSelected();
triggerFieldObject.fireEvent('recordSelect',selected);
}
Inside your event processing (Will be on TriggerField):
onRecordSelect: function(record) {
// Now you have access to the selected record.. process it,
// Set the trigger field value etc
this.setValue('Your Value for Trigger Field');
}
Note: This is a skeleton code and not a complete solution. You will need to add your code according to your requirements.

JQgrid:Get the action from the pager

how can i get the action (what button was clicked) when a button is clicked in the pager?(edit, del, add...)
You probably means button of the navigation bar or navigator (see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:navigator).
You can implement what you want with at least three different ways:
You define your custom buttons which look like the original add/edit/del buttons (see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:custom_buttons) and use {add:false, edit: false, del: off} parameter of navGrid to switch off standard buttons.
You can use addfunc, editfunc and delfunc if you want replace the default add/edit/del functions.
You can use onclickSubmit or afterSubmit or some another supported events (see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:form_editing#events) of add/edit/del button to do some additional action on click the buttont or on submit.
You can chose the way which is the best for your requirements.
You can use the grid onPaging event:
This event fires after click on [page
button] and before populating the
data. Also works when the user enters
a new page number in the page input
box (and presses [Enter]) and when the
number of requested records is changed
via the select box. To this event we
pass only one parameter pgButton
(string) which can be -
first,last,prev,next in case of button
click, records in case when a number
of requested rows is changed and user
when the user change the number of the
requested page.requested page.
Also there are beforeRequest and LoadComplete events. Examples that worked for me are as follows:
beforeRequest: function () {
$.blockUI();
//alert("before request");
},
loadComplete: function () {
//alert("load complete");
$.unblockUI();
}