Hide and show Report region when no data found - javascript

I'm using APEX 5 page to show a classic report region, I want to hide this region when no data found.
I used javascript code in Page HTML Header but it's not working:
<script type="text/javascript">
var has_rows = document.getElementById('news_region').rows;
if (has_rows==0){
$("news_region").hide();
}
</script>

Well, a simple option is to use region's "Server-side condition" whose type is "Rows returned", while the SQL query is just the same as report region's query.
It works OK, no doubt in that, but I don't know it'll behave when the query is heavy (returns a lot of rows, selects from huge tables and stuff). Though, I presume it won't cost much to try it.

Related

Trying to determine what field is referenced in "document.getElementById"

Migrating a SharePoint site from on-premise 2013 to SharePoint Online. Ran across a page that does not work after migration. Key point is that I cannot figure out what List Column is referenced in document.GetElementByID command in existing code
I know how to determine internal name of field, but not the actual ID.
function PreSaveAction(){
disposition = document.getElementById("ctl00_ctl32_g_6b054a37_d068_47a5_930e_0789f69b5ab1_ff51_ctl00_DropDownChoice");
if (disposition.options[disposition.selectedIndex].value != "Withdrawn"){
disposition.options[disposition.selectedIndex].selected = "";
}
for (i=0;i<disposition.options.length;i++){
if (disposition.options[i].value == "Withdrawn"){
disposition.options[i].selected = "selected";
}
}
return true;
}
It appears that if I determine the List Column the above is referring to in getElementByID, I need to find the same ID for the List Column in the destination List/Site. I would then update the code to use THAT id.
Just a little lost on how to determine the ID of List Columns.
Thanks in advance for any suggestions.
JS has two method to get element reference, document.GetElementByID("el_id") and document.GetElementByName("el_name"). Your tag will look like <select id="mySelect"> or <select name="mySelect">.
Do a search for your id in your main pages and in all the included script files. If you can't find it, their is two possibility, the id are auto generated by a dev tool or SharePoint and do not match any more or everything is the same and the page did not work in the old environment in the first place witch is often the case.
As a dev guy, you have to remember that everybody lie but computers do exactly what the code says :-)

Servoy - Getting all data from db table to display as list

I am relatively new to Servoy and Javascript so that might be why i can't get this to work but here goes:
I am trying to get a label to display all of the data from a specific column from my database table in a list.
I tried to add a dataProvider but that adds only one record per page.
I need the items to be listed below each other so it makes it easier for me to see.
I have also tried adding:
function firstName(){
foundset.loadAllRecords();
return;
}
and setting it as an onRender to see if that displays everything
Thanks in advance
If you look for the answer then here it is:
Use a label and set the text of the label to
%%list_display%%
Set your form layout to Tableview
The answer for above was using Servoy Developer and PostgresSQl

jQuery: retain default selection after sorting <option>s in <select> filter

Magento's admin Product Grid has <select> filters for searching products.
Some of those are notoriously unsorted (ie. attribute_sets).
Because I keep discovering this unsorted behaviour in too many locations to fix on the php side, I'd like to use a js approach to fix it.
I got the sorting part finished, that part is done.
But after .append()ing the resulting set back the pull down menu loses the previously selected option. (ie. the filter that was used to load the grid)
I'm missing something basic, but I don't know what.
Here's my code in jsfiddle
*Cleaner code w/o my debug msgs jsfiddle
like I said, it was something basic... I don't know why I could not figure it out yesterday, but anywho:
before sorting:
var whichSelectedVal = $(elid).val(); // stores the current option
after sorting:
$(elid).val(whichSelectedVal); // re-selects the stored option
This works even for the blank filter option, yay for me, no extra work needed to account for that ;)

Getting free of scrolling up after submit in Oracle Apex

Good evening to everybody.
At this moment I'm working on a new page for Oracle Apex and again I have trouble with Interactive Report. My page (let it be named 500) consists of Interactive Report with id rep_main and Classic one with id rep_child, which are connected by master-detail logic (I choose the row from the main report and then I get the rows in the child one depending on my choice). Also every row of the main report has several buttons (precisely tags "a" with links like "javascript:..."), which call dialog windows for updating data of the chosen row.
My aim is to make page more comfortable for users: firstly, the chosen row from the main report should change its color; secondly, the reports should refresh correctly. The second condition means, that, after I choose the rown in the main report, the pagination must not change and the view of the page must not scroll up by itself.
I managed to make the master-detail logic and recoloring the rows (thanks to Stack Overflow for helping me with this task) in my IR, but I have some difficulties with the condition of correct refresh. Apart from JavaScript/jQuery functions, I have to call standard Apex function apex.submit, because if I don't do this, pagination of my IR won't save, but at the same time the page scrolls up by itself, which is very unlikely for users. Moreover, the pagination resets after any dialog window appears.
I've tried to find solution in Google, but all is in vain. I hope that somebody knows if there is any workaround in my case (against the scrolling up at least).
I use Oracle Apex 4.2.6.00.03 and application is executed mainly through Mozilla Firefox. The code I wrote for my page 500 is written below in the current post.
On the page load executes the process with PL/SQL lines like this:
:P500_MAIN_ID := APEX_UTIL.GET_NUMERIC_SESSION_STATE(P_ITEM => 'P500_MAIN_ID'); --receiving the chosen row's ID saved in session
The main report region header contains the following script:
<script>
$("#rep_main").find("table.apexir_WORKSHEET_DATA td).live("click",function(){
var chosenOne = $(this).find("span").attr("id"); //finding ID of the chosen row
chooseMAIN(chosenOne);
apex.submit({set:{'P500_MAIN_ID':chosenOne,'P500_CHILD_ID':null}});
});
</script>
In this code P500_CHILD_RN is the item for saving ID of child report's row and the function chooseMAIN is:
function chooseMAIN(docID){
$.post('wwv_flow.show',
{'p_request' : 'APPLICATION_PROCESS=SET_MAIN',
'p_flow_id' : $v('pFlowId'),
'p_flow_step_id' : $v('pFlowStepId'),
'p_instance' : $v('pInstance'),
'x01' : docID},
function(data){
//for the opportunity to get the ID in pure JavaScript
$("#P500_MAIN_ID").val(docID);
$("#P500_CHILD_ID").val("");
$("#rep_main").trigger('apexrefresh');
$("rep_child").trigger('apexrefresh');
}
);
}
The process SET_MAIN looks this way:
begin
APEX_UTIL.SET_SESSION_STATE(P_NAME => 'P500_CHILD_ID',P_VALUE => NULL);
APEX_UTIL.SET_SESSION_STATE(P_NAME => 'P500_MAIN_ID',P_VALUE => APEX_APPLICATION.G_X01);
end;
p.s. Earlier I asked some help with IR here, but I still haven't found proper solution (except making a submit, which has its side effects I said about).
what you really want to use in this case is the FOEX plug-in because its AJAX based so you don't need to submit.
FOEX website
And do yourself a favor and move away from 4.2 you'll thank me later..

jQuery not updating SOME spans

I am building a web-based tool for the role-playing game GURPS. Data is maintained in several XML files that are loaded into arrays. Based on changes the user makes, data is re-populated into various spans, inputs and dropdowns from the arrays. No problem so far.
To give the user more feedback, I have a added an anchor that does a hover pop-up that shows the details of the current weapon. For the initial coding, these values were hard-coded while I worked out the rendering issues. Still no problems yet.
Now I am trying to actually populate the hover pop-up with real data. I can not get it to load the real data into the span! I have debugged the function and am certain that I have extracted the data I want. I have used similar lines of code to populate other parts of the web page.
Specifics: I want to replace the "aa" in the span below:
<span id="weaponName1" name="weaponName1" class="weaponName">aa</span><img src="Images/Firearms/Makarov_Suppressed.jpg">
The code I am using to try to re-populate the span is:
function loadWeaponStats(person, weaponID) {
// Load stats of the current weapon into the "Details" anchor fly-out
for (xx1=0; xx1<WeaponsArray.length; xx1++) {
if (weaponID == WeaponsArray[xx1][0]) {
weaponName = WeaponsArray[xx1][1];
alert("weaponName: "+weaponName+"\nperson: "+person);
$("#weaponName"+person).val(weaponName);
xx1 = WeaponsArray.length; // Kill the loop
}
}
}
The alert() is simply to confirm that I have the correct data. The following line should re-populate the span, but it does not.
All HTML, CSS & JavaScript can be found at GURPS Combat Calculator
Pulling out what little hair I have left.
Thanks
You can also do as below:
$("#weaponName"+person).text(weaponName);
you can't use Val() method here.

Categories