SAPUI5 Association between 2 entities in the backend system? - javascript

I have 2 Entity sets
First one
and the second one
The red marked data in the first one are the same data as in the second one with blue marks.
I need the red one in the second pictures. So for example I got in this picture the entityset from the first picture of metadata there is Personalnummer, Mvorname, Mnachname. It should stay always Static.
Info: I got a calendar, when I click I want to change the Dauer for the Person for the day which I clicked. So thats why the other one stay static and only the Dauer is dynamic based on the day I click
The Dauer should came from the second picture of Metadata and the Pernr = PernrMitarbeiter, Vorname = Mvorname and Nachname = Mnachname
Is there a way to connect it with a Filter which is based on the Workdate?
So like get the data from the first one and check it with the second entity and than put the Dauer into the fields?

In the OData definition, create an association from ZOOWVM to ZOOWVTU_S - let’s call it duration - with cardinality 1:0..1 over the three foreign key fields. Then you can access the second entity via links of the form /ZOOWVMs(PernrMeister=‘a’,Auftrag=‘b’,PernrMitarbeiter=‘c’)/duration.
I do hope these names are scrambled for privacy’s sake. If they aren’t, you should really consider giving your entities and properties properly readable names.

Related

How to access an entered Interactive Grid column value in a Javascript dynamic action on the Change event in order to ensure uniqueness

I am trying to prevent duplicate items from being entered in an Interactive Grid in Oracle Apex 20.2. I do get a unique constraint error when this happens, but this is for a barcode scanning stock control app and the unique constraint error only happens when saving after scanning a room with lots of objects. It is then very difficult to find the duplicate field. You also cannot use sort, since that wants to refresh the page and looses all your scanned items. I cannot presort because I want the last scanned item on top.
I was able to add Javascript on page load that creates an array with all the barcodes. I then check this array when scanning and do not add new Interactive Grid rows when a duplicate barcode is going to be added to the array.
In addition to this I need to add the same for when an Interactive Grid row is manually entered. For this I wanted to add a Javascript dynamic action on the barcode column in the Interactive Grid, in order to once again check the global array for uniqueness. However I have several issues: I cannot figure out how the get the entered barcode value in the change dynamic action Javascript, sometimes it shows the previous changed value (might be this bug although I am in 20.2) and the Change event also seems to fire twice when hitting enter after entering a value (once for the new row (this time my code works unlike when hitting Tab) and once for the next row below). The last one seems bad, since then it will try to check existing values (the next row) and give errors that should not happen; however I do not see a more appropriate event like On Row Submit. Not sure if there is a way to check whether the value changed on the Change event.
The code I currently have I got from here. I am assuming this means Oracle Apex does not have a standard way of getting an Interactive Grid column value in a Javascript dynamic action. Not sure if this has changed in 20.2 or 21. The code I have is:
console.log($(this.triggeringElement));
var grid = apex.region('LINES').widget().interactiveGrid('getViews', 'grid');
var model = grid.model;
var selectedRow = grid.view$.grid('getSelection');
var id = $(selectedRow[0][0]).data('id');
var record = model.getRecord(id);
let bcode = model.getValue(record, 'BARCODE');
console.log(id);
console.log(record);
console.log($(selectedRow[0][0]));
console.log(bcode);
if(barcodes.includes(bcode)) {
apex.message.showErrors([{
type: "error",
location: "page",
message: "The entered barcode is already in the list.",
unsafe: false
}]);
}
When I console.log(record) I can see values that I enter into the barcode column, but I do not know how to walk the object tree in order to retrieve the value out of the record. I do not understand the object it shows me in the console log. It does not seem to correlate with the dot access traversals that others are doing in the above code. I can see the record array at the top, but for that the barcode column shows the previous value; below that it does however show the newly entered value as the third (2) index, but I do not know how to write Javascript to access that.
If I can access the previous and new value from the record object I could check for changes and also compare the new value against the global array. How do I access these values in the record object or is there a better way of achieving my goal? bcode prints the previous value, so I guess I already have that if that is not a bug.

Display value form rows marked in spotfire visualization?

After marking in a visualization i want to capture a particular column value form rows marked and display it in text area .
thanks
The way to do this is to add a data function to the analysis. Define the function as a identity function, i.e.:
output <- input
This can be an R function or TERR function. If you use TERR it can execute locally rather than going to stat services (though web player will need to use stat services anyway).
Now, connect the data function to your analysis and as input you make it depend on the current marking. Assign a value to the input parameter by creating an aggregation on the column with the value you are looking to collect.
Assign the output of the data function to a document property.
The image linked here shows a sample of how to configure the input parameter:
Sample input parameter config
To show the result in the text area you create a normal property control of your choice in the text area, and attach it to the document property that is written to by the R/TERR script.

Jquery or javascript to display "more information", data taken from SQL database

i'm not sure if this is possible, I've looked into it but can't seem to find anything.
I'm just going to give a quick example of my scenario. Basically I have two main tables Classes and Cars. For example, Executive class will have S-Class, BMW 7 Series and so on, compact will have mini cooper etc.
Now, on a website what I'm trying to do is through javascript/ajax/jquery (not quite sure what method) is to display the Class and allow the user to be able to click on it then beneath display the vehicles
Now, I have an sql database and that is always changing, cars can be edited or changed etc so when I click a class, obviously updated information needs to be displayed.
However, after doing some research I can't seem to find a way which does not involve hard coding information into the page?
Any help please?
You need to create two dynamic pages - one to retrieve categories (classes) and one to retrieve cars within a chosen category.
You haven't mentioned which server-side language you're using so I'll assume PHP for the moment, but it'll work the same for any language you choose.
Part 1 - categories.php
query the database and retrieve a list of all categories (name, id)
output these in a SELECT list (or similar)
include a DIV other container to fill in any retrieved cars for that category
The output would be something like this:
<select id="categories">
<option value="-1">Select a category</option>
<option value="1">Executive</option>
<option value="2">Compact</option>
</select>
<div id="cars"><!-- cars go here --></div>
I have used the attribute "value" to store the database ID of the category, for later retrieval via JQuery.
Part 2 - cars.php
takes a URL parameter "category" to determine which category to use to query for cars (e.g. cars.php?category=1)
query database with selected category ID and retrieve matching cars
output results in HTML list (or similar)
Part 3 - JavaScript
Once you have the above stuff going then you can simply pick up the ID from the category list and send out a request for the cars when the option changes. On your category.php page you would include the JQuery library first, then this script:
JQuery(document).ready(function($){
// capture change event on select list
$("categories").on('change', function(){
// get current value
var value = $(this).val();
// retrieve cars using AJAX, passing category value
$.get("cars.php", {category:value}, function(data){
// html list for cars retrieved here as data - fill in the cars html
$("#cars").html(data);
});
});
});
There are of course many ways to skin the cat, but this is probably the simplest for starters. If you're concerned with getting the most up to date information for every request, then you need to go back to the server each time the category changes. If database changes are likely to be less frequent, and the data set isn't huge then you may consider retrieving it all in one lump of JSON and using that as a local "database" to do lookups against.

sencha touch: 5 simple questions

I am new to sencha touch and I have some simple questions. I don't need 100% working code as answers, but if someone could point me in the correct direction, this would be great. But keep in mind, sencha touch is new to me. I use sensha touch 1.x.
Let me first explain what my app does. It shows a list with items (fetched from a db via json proxy). You can tap on a item, which shows a form. You can then update or delete the item. On the list screen you can also add a new item. Quite simple :-)
Here are my questions:
1/ Datepickerfield:
In the form there is a datepickerfield. The default format is month/day/year. I live in Europe so the formate should be day/month/year. With slotorder, I can change this. But the field itself still has the wrong format. I tried to fix this with a listener:
change: function() {
this.fieldEl.dom.value = this.getValue().format('d/m/Y');
}
This works when selecting a date. But when tapping an item from the list, the datepickerfield remains the wrong format. I tried using other listeners like afterrender, scope, etc. But nothing works.
2/ Numberfields:
In the model I have a field duration. It is of the type time in the sql-table. So the format is hh:mm:ss. In the form I have 3 numberfields. One for the hour, one for the minutes and one for the seconds.
How can I make the field duration split up into 3 parts and filled in the 3 numberfields when tapping an items from the list?
3/ Contextual selectfield
In the form there is a selectfield with values that depend on the user that is logged in. If user 1 is logged in, the values should be x, y, z. If user 2 is logged in, the values should be x, a, b, etc.
So, when opening the form the selectfield should be pre-filled with data. It should call a function from the server to fetch the correct data. How can this be achieved?
4/ Refresh list like twitter
I want the list to fetch additional items when reaching the end (like twitter). I found something on the Internet: PullRefresh plugin. But I can't make it work.
Any ideas?
5/ Style the list
Is it possible to style each item of a list separately? You can use styleHtmlCls, etc but that styles the whole list.
Thanks a lot in advance.
1 - This is easy set:
picker: {
slotOrder: ["day","month","year"]
}
2 - I dont understand 2 give more clarity
3 - You need to use local storage for this
4 - For paging try this link sencha list paging plugin
5 - You cant directly style each item differently but you can define a style for each item in the list by setting its style config
For those who are interested, my solutions.
1/ This code Ext.apply(Ext.util.Format, {defaultDateFormat: 'd/m/Y'}); which sets the format for all the dates in the application.
2/ I created in my model 3 extra fields. It are 3 "convert" fields for the field "duration" which is in format "hh:mm:ss". This is the code (the same for the fields duration_m and duration_s):
name: 'duration_h',
convert: function(value, record)
{
var duration= record.get('duration'),
splits = duration.split(":"),
duration_h = splits[0];
return duration_h;
}
In my form I use now 3 numberfields linked to those 3 extra fields. When saving you data you must not forget to do
PHP Code:
model.set('duration_h', '');
Otherwise those fields are not set in the model and keep being empty.
3/ and 4/ I did not yet solved.

Populating a drop down based on a text field Javascript/Coldfusion 8

I have a page that has around 30 different entry fields, one of the top fields is a textfield and after this is filled in, I want to populate a dropdown and a textfield. I currently have it calling a javascript function, however my main problem is that I need to query the database to find out what value to populate the fields with.
Here is the type of thing I was trying to do:
function populateState(){
<cfquery name="getState" datasource="#application.dsn#">
SELECT STATE_CODE, CODE_ID
FROM LERG_LATA_V1 LEFT OUTER JOIN Code ON STATE_CODE = CHAR1_TX
WHERE NPX = #NPANXX#
</cfquery>
}
And then after that I would need to read the result and select that element. Any suggestions on how to do this? Most of what I am finding on my google searches are saying you cannot mix cf and js since they execute at different times.
You need to either create a state JavaScript array with your query, and then reference that in your javascript, or use the built-in cfselect tag binding to make this happen. Here's a simple example of how I do this:
http://www.dansshorts.com/post/cfselect-binding-and-selectedvalues
Dan

Categories