Get Value on a Window with GridPanel using ExtJS - triggers

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.

Related

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

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.

Microsoft Word JavaScript API - event handler for text selection in document

I read JavaScript API for Office and I couldn't find a handler to notify when user select a text in the word document.
I am aware that we can copy the selected/highlighted text from document as follow:
Word.run(function(context) {
let body = context.document.body;
// ask for the user selected text
let range = context.document.getSelection();
});
This approach is not a registered callback or an event. With this approach I have to request update or to check if user selected anything.
Is there an existing function that I can register for getting notified for user interaction with document?
Thanks in-advance for your help
the getSelection() method does not actually make a selection in the document. it gives you the range that its currently selected. in order to get the events you need to subscribe to the document selection event, you can achieve that fairly simple just with:
function subscribeToEvent() {
Office.context.document.addHandlerAsync(Office.EventType.DocumentSelectionChanged, handler);
}
function handler(evtArgs) {
// here you can handle the event.
console.log("select");
}
On the other hand the range.select() method WILL trigger the selection changed event if you want todo it programmatically. Please check out this Script Lab snippet, it basically subscribe to the event on load, then if you click the RUN button you will see that the last paragraph gets selected and the event triggered.

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.

Check if a record is selected from a dataPointGrid

I have a dataPointGrid and I want to check if a record from it is being selected (mouse clicked on)
Data point grid above. I want to check if a folder (record) is being selected.
Is there a method that does this?
Add ListGrid#addSelectionChangedHandler() on list grid that is called when (row-based) selection changes within this grid. Note this method fires for each record for which selection is modified - so when a user clicks inside a grid this method will typically fire twice (once for the old record being deselected, and once for the new record being selected).
Look at the ListGrid#setSelectionType() as well that defines a listGrid's clickable-selection behavior (MULTIPLE, SINGLE, SIMPLE or NONE)

How to add a custom selection Handler to a celltable

I want to add a special selection model to the celltable. Basically the function i want to have is to select a row on the table which is located on left side, a corresponding form will pop up on the right side.
I know so many people will use the singleSelectionModel with SelectionChangeHandler.
But there is problem with this method.
For example, if I select row 1 on the table. the form pop up. I close the form by clicking the close-button. Later then, I select the row 1 again, the event is not fired, because it is SelectionChangeHandler. I have to select other row before doing this. This is no good.
So I think there are a few ways to do this:
Make the row deselected right after I select the row.
Use click handler to fire the event ( to pop up the form)
Use other selection model with other selection handler to do this. (I have no ideas about this though)
So my questions are,
Does anyone know what kind of other selection handler I can use for this.
If I use the click handler on celltable, will there be any problem?
I just want to learn more about this. So any ideas will be welcome.
Thanks a lot.
Best Regards.
Use NoSelectionModel. It won't update the table view after the row is selected. That is, even if the same row is selected, the change event is fired.
//Here 'Contact' is the datatype of the record
final NoSelectionModel<Contact> selModel = new NoSelectionModel<Contact>();
selModel.addSelectionChangeHandler(new Handler() {
#Override
public void onSelectionChange(SelectionChangeEvent event) {
Contact clickedObject = selModel.getLastSelectedObject();
GWT.log("Selected " + clickedObject.name);
}
});
table.setSelectionModel(selModel);
I have using cell table in my each project. The better way to just deselect row manually as u mention. and make change css such as selected cell table's row look not changed after selection.