How to pass Orbeon dropdown control selected value to script - xpath

The following code works for radio buttons.
<xf:select1 id="User-Status-control" appearance="full" bind="User-Status-bind">
<xf:itemset ref="instance('User-status')/item">
<xf:label ref="#value"/>
<xf:value ref="#name"/>
</xf:itemset>
<xf:action ev:event="xforms-value-changed">
<xxf:script>
var op1 = ORBEON.xforms.Document.getValue(this);
alert("op1 : " + op1); // print the selected radio button ID.
</xxf:script>
</xf:action>
but it does not works for dropdown
<xf:select1 id="User-Status-control" bind="User-Status-bind" appearance="dropdown">
How can I get the value of an Orbeon dropdown control?

Because <fr:dropdown> AKA <xf:select1 appearance="dropdown"> is a compound control, you have to go search for the nested .xforms-select1 control. Something like:
ORBEON.xforms.Document.getValue(ORBEON.jQuery(this).find('.xforms-select1')[0])
I have updated the doc to reflect this.

Related

E4 RCP How to set selection of ToolBarItem that contains Radio Buttons

In Eclipse E4 (Luna), using the application model to create parts, handlers, commands, handled menu items etc, (these are not created programatically). I have a toolbar. This contains a sub-Menu item called "Filter" that contains another sub-menu of two filters. The two filters are two Handled Menu Items which are set up as "Radio" Buttons.
When I select the appropriate in the UI of my running app from the selection, the Radio button switches just fine to the selected Item. However I would like this selection to update (deselecting one Radio button and selecting the appropriate radio button of the handled menu item) when my ViewPart changes through other UI selection. Currently my ViewPart updates, but the Radio buttons are on the same previous selection through the UI.
Is there a way in which I get access both Handled Menu Item's IDs and set the selection (one to false, the other to true) when the viewer is updated.
Image of design is attached below:
Hierarchy of the application model is as follows:
Thanks in advance,
Marv
You can use the model service to find menu items. Use something like:
#Inject
EModelService modelService;
#Inject
MApplication app;
List<MMenuItem> items = modelService.findElements(app, "menu item id", MMenuItem.class, Collections.emptyList(), EModelService.IN_MAIN_MENU);
Once you have the MMenuItem you can call the setSelected(boolean) method to change the selection.
To find a menu item which is in a Part menu use:
modelService.findElements(app, "menu item id", MMenuItem.class, Collections.emptyList(), EModelService.IN_PART);
(IN_PART argument instead of IN_MAIN_MENU).
You could also specify the MPart rather than the Application as the first argument to findElements which may speed up the search.
For menus as a child of a Tool Bar Item it appears that the model services cannot find these directly. However you can find the Tool Bar Item and look at the menu yourself:
List<MToolItem> items = modelService.findElements(app, "tool bar item id", MToolItem.class, Collections.emptyList(), EModelService.IN_PART);
MToolItem item = items.get(0);
MMenu menu = item.getMenu();
List<MMenuElement> children = menu.getChildren();
... search menu elements
I solved this by starting with MPart PartID and drilling down to the HandledMenuItems on which I wanted to set the Radio Button selections, then setting the selection property for each individual HandledMenuItem.
This can probably be refactored to be more concise, but I've left the code with each step to have the solution easier to read.
BTW, in every instance / combination of the EModelService methods, the list returned a size of 0. So I'm not certain if that will work for what I'm trying to achieve. The following does work, although I'm not certain it is the most efficient means.
I hope this helps others.
// Get view part
MPart viewPart = _partService.findPart("part_id");
// get list of all menu items from the Part
List<MMenu> viewPartMenu = viewPart.getMenus();
// Get list of ViewMenus from viewPartMenu there is only one View Menu so it will be index 0
MMenu viewMenu = viewPartMenu .get(0);
// Get list of MMenuElements from the viewMenu - the children in the view menu
List<MMenuElement> viewMenuElements = viewMenu.getChildren();
// This gets me to the 2 HandledMenuItems
// Upper Most HandledMenuItem Radio Button is at viewMenuElements index 0. This is cast to MHandledMenuItem
MHandledMenuItem upperHandledMenuItem = (MHandledMenuItem) viewMenuElements.get(0);
// Set Selection
upperHandledMenuItem.setSelected(false);
// Lower Most HandledMenuItem Radio Button is at viewMenuElements index 1. This is cast to MHandledMenuItem
MHandledMenuItem lowerHandledMenuItem = (MHandledMenuItem) viewMenuElements.get(1);
// Set selection
lowerHandledMenuItem.setSelected(true);

Kendo UI Grid Edit popup's change update method return values

the normal way in kendo ui grid update data is add a edit popup.
What I want is, Think I change a value in text field.In update I added switch case and change the submit value. Then It will add that value and return that values to the grid. But I want to do is when get the return value and change it and show a different value in the grid.
Here is a example.....
In edit popup it has a input text field. I submit a value as "A". In the update I add a switch tells that If the value is "A" change the submit value to 1(number one).
Then it submit the value and show the value in grid as "1" not as the "A".
How I do this ???
I think you want a custom handler. In the grid you toss in this:
edit: function(e) {onEdit(e)},
and then on top of the page you do whatever logic you want to do
function onEdit(e) {
if (true) {
$("#Whatever").text('Hello') //Whatever in this case is a field in grid

LiveCycle drop-down list change event only works on second change

I want a Text Field to appear when a certain item is chosen from a drop-down list. I'm using a change event.
if(this.rawValue == 1){
Tolerance.presence = "visible";
}
else{
Tolerance.presence = "hidden";
}
The problem is that the Text Field presence does not change immediately when a selection is made, but only after I go back to the list box and select again (any value, not just the same one).
The new value of the dropdown only registers after the change event. This means this.rawValue points to the old value of the dropdown in a change event.
Either move your script dropdown exit event or make use of the event.newText in the if conditional in the change event.

Kendo grid group header customize to show the value and more

I have a Kendo grid that is groupable. The initial display needs to show all data items with no groupings displayed, i.e no 'group' and 'groupHeaderTemplate' are defined.
The grid contains a column (Suspension) where the value displayed is a translated dataitem value, i.e. if value > 10, display '*'.
When the user drags the Suspension column header cell to group, how can you customize the group header to show the value that it is grouping on plus the display 'value', i.e. 10-* ?
Do you mean on the button to turn off the group, or the group header text above each group in the grid ?
If the button to remove the grouping, I think you are stuck doing that manually.
If you mean the text above each group, columns have a groupHeaderTemplate property you can set.
groupHeaderTemplate: "Grouped By Name: #= value #"
See sample http://jsbin.com/IbITaT/2/edit

Fetching jqgrid row on click of hyperlink

I am facing problem in Jqgrid. I have a column with hyperlink and on the click of that hyperlink I want row data. Is this possible using Jqgrid. when I am using "getGridParam" I am getting row id as null.
There are two possibilities you can try here:
1) You can use a custom formatter to create the hyperlink, and have a custom attribute on the link where you put in the rowid (prefix the custom attribute name with 'data-' to keep it html5 compatible). Alternatively you could call a javascript function explicitly passing the row id.
2) Instead of the hyperlink's event itself, try using the onCellSelect event of jqGrid where you get the row and column id of the clicked cell, even if its a hyperlink. But this would trigger the event even if the user clicks anywhere inside the cell, not just on the link!.
I'm sure you found the answer to this by now but for some of you using ASP.NET WebForm here is what I used.
Create the Custom Formatter and add it to the column where you want the link to appear:
My columns are from a database I use a Select statement as so:
switch (jqGrdCol.DataField)
{
case "xxx":
CustomFormatter hypLinkxxx = new CustomFormatter();
hypLinkxxx.FormatFunction = "xxxformatOperations"; --> **JavaScript Function**
jqGrdCol.Formatter.Add(hypLinkxxx);
break;
}
Then in the Javascript function:
function xxxformatOperations(cellvalue, options, rowObject) {
return "<a href=somefile.aspx?xxx=" + rowObject[0] >" + cellvalue + "</font></a>"
}
I get the value of the column as a hyperlink.
I had a similar issue and was did look into your question to figure out a solution and I have found out a solution to this.
The solution is by using onCellSelect: function(rowid, index, contents, event)
this gives the rowid and contents ie the content of the cell you have clicked or selected
therfore you can get the entire row of contents which includes your hyperlink as well

Resources