Kendo UI TabStrip e.preventDefault() doesn't work - kendo-ui

Two problems:
1.)
e.preventDefault() doesn't work correctly with Kendo UI TabStrip when somewhere
$("#tabstrip").kendoTabStrip().data('kendoTabStrip');
appears.
2.)
Imagine the User clicks on another tab, but has unsaved changes.
A dialog pops up and ask if he wants to discard the changes and go to the tab or
if he wants to stay on the active tab to save his changes.
My solution doesn't work. Because of the 1. Problem I guess and because
.data() somehow reinitialises the TabStrip?! What is wrong?
Here is a (not) working example
http://jsfiddle.net/Nakkvarr/w9586/
Any ideas on this issue?

The reason it doesn't work for the first tab is because you initialized the tab strip twice on the same element $('#tabstrip'). Since you bound the select event on the first initialization, the subsequent initialization overwrote it (the select event isn't handled anymore). You even answered the problem yourself by stating that it works if you comment the second initialization line out.
I'm not entirely sure what you're trying to accomplish with the setTimeout() function in the second example. It's unnecessary.
Using e.preventDefault() works as expected. JSFiddle: http://jsfiddle.net/w9586/6/

Related

How to Asynchronously Show a Create New Button On a CRM Sub Grid?

I need to hide the "Add New" button on a sub grid until certain criteria are met. Calling Xrm.Page.ui.refreshRibbon will trigger my JS function defined in my Enable Rule, but I can't get the + button to show up.
Is this unsupported, or is there some methodology to get this to work?
Seems like you have to do few extra trick.
Refreshing the subgrid command bar
You will find that when the form is loaded, if there is a value in the attribute you have referenced in your enable rule, the Add New button will be visible. If however the value changes, the sub-grid command bar will not automatically refresh to reflect the new state. Upon adding or deleting rows in the sub-grid the command bar is refresh – but this isn’t much use in this case.
The main form command bar can be refreshed using Xrm.Page.ui.refreshRibbon() however this will not refresh sub-grid command bars. Instead, we can add an onchange event to the fields that are used in our VaueRule and call:
Xrm.Page.data.save();
This will refresh the sub-grids and re-evaluate any of the EnableRules however it will also save any other dirty attributes and so should be used with caution if you do not have auto-save enabled.
Ref: https://ribbonworkbench.uservoice.com/knowledgebase/articles/489288-show-or-hide-the-add-new-button-on-form-sub-grid
Arun Vinoth did find a great article to describe the issue, but actually I've found that just calling refresh on the grid itself was all that was actually required.
It's important to note, that this does not re-run the enable rules, just shows the button if the state has changed.

Kendo UI Grid inline edit not work when use ObservableArray as data for data source

I'm trying to use a kendo.data.ObservableArray as data for data source of the grid. It shows ok. When edit inline, change a field, then cancel, the values are changed. When clicking edit, then click edit on another row, the last one remains in the edit mode. Sometimes cancel not work. On the array it works as expected.
I took the Kendo UI Demo, http://demos.telerik.com/kendo-ui/grid/editing-inline, to reproduce the issue. Here is the issue: http://dojo.telerik.com/uLiCi/2
Does anyone have any idea why so strange behavior?
In my opinion, it should work with both, array and observable array.
Thanks in advance

Get value from autocomplete text field in ApEx

I want to create a dynamic action, that will set a value to an item on the page, when the value of another item (autocomplete text field) is set.
So the proccess goes like this:
Click on the autocomplete field
type some letters
choose one of the suggested values
I cannot find an event that will be executed when the selection of one of the suggested values happens. This way, I cannot see how I can read the value of the autocomplete field, once a suggested value is selected.
The change event doesn't fit my needs, it doesn't execute when one suggested value is selected.
I had the same problem, found this link: https://community.oracle.com/thread/2130716?tstart=0 and modified my dynamic action as follows to get the desired behaviour:
Event = Custom
Custom Event = result
From the link:
the problem seems to be the default behavior of the browser. When you
enter some text into the autocomplete and the list is displayed, the
focus is still in the text field. Also if you use the keyboard cursors
to pick an entry the focus will still be in the textfield. That's why
the change event of the textfield doesn't fire. It only fires if you
leave the field.
On the other side if you pick an entry with the mouse, the browser
will remove the focus from the text field for a moment (before the
JavaScript code puts the focus back), because you clicked outside of
the field. But that's enough so that the browser fires the change
event.
I had a look into documentation of the underlaying jQuery Autocomplete
widget
(http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/) and
there is actually an event called "result" which can be captures if an
entry is selected from the drop down list.
Try "Lose Focus" as event. It will trigger your dynamic action when you leave the autocomplete field, i.e. your curosr is moved to another field.
This probably depends on the APEX version you are using.
In case of 18.2, because the underlying component is based on Oracle JET's "inputSearch" component, you need to use following configure to capture the select change event for text with autocomplete:
event: Custom
custom event: ojupdate
Reference:
https://docs.oracle.com/cd/E87657_01/jet/reference-jet/oj.ojInputSearch.html#event:optionChange
I turned on the browser console, then turned ApEx Developer toolbar debug, and found that, on the contrary, the "Change" event does fire upon user clicking with the mouse on one of the selections. However if the user uses keyboard (type a few letters to narrow the list down, then use down arrow key to arrive at desired value, then press enter) then the Change event does not fire, just as you say.
Moreover: even when you do get the value sent back via mouse-click initiated Change event, the value isn't the autocomplete's complete and valid value, but instead the possibly partial and wrong-case value just as typed by the user. I.e., the the change event's submission of the value precedes the autocomplete's substitution.
The answer that #VincentDeelen gave is the best alternative that I can see, although it doesn't quite give that "instantantenous synchronicity" feel. You could maybe use the "Key Down" event, but be careful with that. You could get a really excessive amount of web and db traffic as each and every keystroke (including corrections) results in another firing of the dynamic action.
Testing environment: ApEx 4.2.3 with Chrome 33 as well as IE 9.
p.s. This might be worth a mention to the ApEx development team as well.
It's not really ideal, but you could use onfocus(). I'm looking for the same thing you are, I think, a custom event that fires when the selection of a suggested value happens. I haven't found it yet though and that is my work-around for now. It will run whatever function you've created for this initially with no value, but once the selection is made it will return focus and run the function again with the right value. Like I said, not ideal but it works.
Jeffrey Kemp is right. You can set it up through a dynamic action using the custom event, result. You can also register it on page load using document.getElementById("{id}").addEventListener("result", {function}); or $("#{id}").result( function( event, data, formatted ) { //something here });.
Oracle apex 19 now added a "component event" when you create a dynamic action called "Update [Text Field with autocomplete]" - this action is fired when you select a value from the list, but not when you leave the field (similar to adding the custom event "ojupdate").

Flexicious DataGrid FlexDataGirdEvent.EDIT_END special case

I have a Flexicious DataGrid set up, and I have an ItemRenderer set on a certain column. Now, when I am editing an editable cell, and then stop editing it, the DataGrid fires a FlexDataGrid.EDIT_ITEM_END event (or something like that). When this is fired, I want to do a certain action. That's simple enough. The problem though, is I have a special case:
If a user is editing an editable cell and then clicks away from it (which would cause FlexDataGrid.EDIT_ITEM_END fire), but he happens to click on a button which is within the ItemRenderer set on the column, then in that case I don't want to do the action. I don't know how to make an event work like this though.
Basically I'm looking for an event that is FlexDataGrid.EDIT_ITEM_END_AND_CLICKED_ON_ANYTHING_OTHER_THAN_THAT_BUTTON and I'd like to fire that instead of FlexDataGrid.EDIT_ITEM_END. But alas, I checked the docs and that event doesn't exist =-(.
What can I do? Thanks for the help!
Have you tried ITEM_EDIT_CANCEL? This has a triggerEvent which should have a target property that should tell you what display object the click happened on.

How to allow cell navigation in SlickGrid with a Validation Error?

I've noticed that when a validation error occurs, the user is locked into that cell until the error is resolved. Is there a way to allow the user to continue to navigate cells?
This approach works for me b/c I don't commit when they leave the cell, but wait until they click a Save button. So, this button would be disabled while an error exists, but they are still free to navigate cells. Thank you.
You need to implement your own editorLock function, that is passed to options. This feature, just as most of SlickGrid, is poorly documented, ut you can watch through source code of SlickGrid, and search for function called commitCurrentEdit.
The example of editorLock is in the file slick.core.js
Also, before rendering the grid you can try to do this:
Slick.GlobalEditorLock.commitCurrentEdit = function(){
return true;
}

Resources