Calling jQuery on Oracle Apex IRR partial page refresh - oracle-apex

Based on another question I have asked:
How to Remove <a href> Link Tag for a Specific Value using Jquery
where I need to remove the a href tag if the value is 'N'.
All works fine on first load, but since I am using an Oracle ApEx Interactive Report (IRR) and perform a partial page refresh, the solution from my other thread doesn't fire again and so all my values that have a value of 'N' now have a link below it which is not want I want.
Within an IRR, is there a means of firing jQuery code, like on load when the report is partially refreshed, based on column filtering?

Sure is.
With dynamic action: After Refresh
Triggering region: select your IR region
True action: execute javascript code
$('a', this.triggeringElement).filter(function(){
return this.innerHTML === 'N';
}).replaceWith('N');
Or just javascript code
$("#ir_region_id").bind("apexafterrefresh", function(){
$('a', this).filter(function(){
return this.innerHTML === 'N';
}).replaceWith('N');
});
Although you might want to restrict your "a" selector to your actual link column. If you don't, every link in the IR region is selected. It's unnecessary.
$('td[headers="my_link_column"] a')

Related

Oracle Apex set select list value in session state without submit page on change

How save selected value from select list in session state without submit page on change?
Example work with submit page!
Create a dynamic action on change of P245_YEAR
Action type: "Execute Server-side Code"
Language: PL/SQL
PL/SQL Code:
NULL;
Items to submit: P245_YEAR

Not able to make the navbar items dynamic in ember

I have navbar component which I have placed in an application.hbs so that it should be visible always.But I want to change the title of the navbar with each page I visit ( say I am on index page it should say "Home" , if I am on profile page it should say profile,etc).Right now what is happening is navbar title always remains "Home" for all the page.This is happening because the navbar gets rendered onlu during the time it loads the page in browser and after that it doesn't change according to page.
application.hbs
{{top-navbar dp_url=model.profile.dp_url first_name=model.profile.first_name title=title}}
{{outlet}}
Here the I am computing the value of title depending upon which page the user is.
application.js(controller)
if (currentPage === "" || currentPage === "#"){
currentState.set('title',"Home")
}
else if(currentPage === "Userprofile"){
console.log('myStudio');
currentState.set('title',"UserProfile");
}
In here the currentpage has the current url of app and I am comparing it and deciding the value of title for navbar.
But the top-navbar title value gets calculated only for the first time when user load the app in browser and not when I move ffrom one route to another.
I have also tried the Ember.Evented but not able to solve it.
I don't know what Ember.js and Ember-data version are you using, currentState is deprecated since 2.1, anyway looks like you're using a private method intended for Ember internals and not meant to be used in an application.
A possible (but maybe unnecessary complicated) way to accomplish what you want is:
Create a model with the information you want to mutate in the navbar (e.g. navbar-data).
In the route where the navbar is rendered, create and return a record for it using a fixed numeric ID (e.g. store.createRecord('navbar-data', { id: 1, title: "index" })).
Pass the created record to the component (instead of just a string).
Whenever you want to change, peek the record with store.peekRecord('navbar-data', 1) and change the value you want to change in the navbar.
Of course, the record you use for that must not be saved with record.save().

Using Dynamic Action for multiple checkboxes

In Oracle Apex, I am currently creating a form. Within the form there is a checkbox item that shows a LOV. One of the options is labeled 'others'. The goal is to have a text box appear when 'others' is checked. I am unsure on which dynamic action to use for this situation. Could someone help me with this?
If built in dynamic actions in apex wont give you results, you can always patch it up with a jquery or javascript in the main page.
In the main page under javascript>excute when page loads, try this code
$('#P2_NEW_CONTAINER').hide();
$('#P2_NEW_1').click(function(){
if ($v('P2_NEW_1').indexOf('2') != -1) {
$('#P2_NEW_CONTAINER').show();
}
else{
$('#P2_NEW_CONTAINER').hide();
}
});
where
P2_NEW_CONTAINER is the id of the container of your textbox/textfield.it always end with _CONTAINER;
P2_NEW_1 is the id of your checkbox and;
"2" is the return value of the "others" check box
Create text field lets say P1_textthen create a dynamic action with the following options:
Event=Change
Item=P1_Your_Check_Box
Condition=In List
Condition Value=others (the return value of your P1_Your_Check_Box when
others is checked)
True Action=Show
Uncheck Fire On Page Load
Affected Elements>Items= P1_text
False Action=Hide
Affected Elements>Items= P1_text
Check Fire On Page Load

Refresh a region's items during/after apexrefresh

I have a Report region that I am refreshing via jQuery. I have the following code with the region footer to set up the refresh process:
<script type="text/javascript">
var refreshId = setInterval(function(){ apex.jQuery('##REGION_ID#').trigger('apexrefresh');
}, 5000);
</script>
This works correctly, and the report data is refreshed every 5 seconds. However, the region also contains an Item, whose source value is determined via a SQL Query. I want this value to refresh every time the report region data refreshes too, but the triggered refresh doesn't do this.
Looking closer, it seems the report region div does not contain the Item HTML, so the part of the DOM that gets swapped out during the refresh does not contain the item. The item appears inside a sibling table node called apex_layout_#REGION_ID#:
<div class="rc-content-main">
<table id="apex_layout_7017903473906209" class="formlayout" border="0" summary="">
<div id="report_7017903473906209_catch">
<script type="text/javascript">
</div>
I've tried doing an additional .trigger() call passing in the Item's ID instead of #REGION_ID# but confusingly this does the exact same refresh of the report data. I've also tried setting up a Dynamic Action to fire on "After Refresh" on the region that will refresh the Item, but this does something strange too - it fires repeated AJAX calls with no delay and doesn't change the item value.
Any help appreciated.
You can't refresh an item using the apexrefresh event. You are on the right track with the dynamic action: you will need to 'manually' retrieve a new value.
Could you elaborate on how you have set up your "after refresh"-triggered dynamic action for your item? Does it have a true action of "set value" with "sql statement"? Did you inspect the ajax calls? Any errors? Do the calls keep repeating? Also, check the session state (access through the "session" button on the developer bar on the bottom) of the items, and see if the value there has changed.

ASP MVC4 jquery calendar

I'm working with ASP MVC4 jquery calendar. I'm new to this. I have my jquery calendar built so that it highlights particular dates which i passed through array. But now the question is, I have a table of data in database which I got into Model and then used to it retrieve information based on an 'ID' in controller and returned to VIEW. Now I can get the dates from database in the form of table but I want to know, how I can pass those particular dates to an array of JQUERY CALENDAR in VIEW.
Also I imported package:
with core and datepicker functionalities.
But when i click the next arrow or previous arrow, it doesn't show next or previous months.
I can post the code if you don't understand my question. Please help me since I have already spent more than 15 days understanding this.
well, thats an older question but I had a couple of problem myself with datepicker and took me about 3 hours of research until I found the answer ... this is only for poeple like me who'd end up on this while digging up for answers ... *
Jquery UI is already include in .net mvc4, as is datepicker, its in the bundle. you just have to call it by adding this to your layout ( in the head section )
#Scripts.Render("~/bundles/jqueryui")
#Styles.Render("~/Content/themes/base/css", "~/Content/css")
also, make sure you dont have another script render at the bottom of your body, as its by default where the jquery bundle is set (at least it was for me on the default project ) and it cause a bug with datepicker when I used it.
<input id="mydate" name="mydate" class="datepicker" type="text" value="#Model.mydate.Value.ToString("dddd, dd MMMM yyyy")" />
where mydate is the name of the parameter you'll have set in your viewModel, said parameter is a DateTime object ( or DateTimeOffSet ) (the .Value is only if you set the date as a nullable, its not necessary otherwise)
After on the bottom of your view, create a jquery section :
#section scripts{
<script>
$(".datepicker").datepicker({ dateFormat: "DD, d MM yy", altFormat: "yy-mm-dd" });
</script>
}
(dateformat and altformat are optional, give them the value you want or dont use them at all)
as for the array of date ... i'd use a viewmodel, which would contains your array as parameter, and pass this viewmodel between your view and your controller. after that define an Editor template and its should be pretty straighforward to build a table with the dates from there.