I am trying to implement a Variant management in SAPUI5 using Personalization service of sap.ushell.Container. I have written functions to Save, Manage(delete, rename) and select Variants from the drop down. However i see strange behavior when i select a variant in the method mentioned below.
onSelectVariant: function (oEvent) {
var sSelectedVariantKey = oEvent.getParameter('key');
Assume i have existing variants 'A1', 'A2' and 'A3'.
When i SaveAs a new variant with new values (lets call it 'X1'), the new variant is created. Then i select another already existing variant from dropdown( A1 or A2 or A3), i see the corresponding values. Now i again select the newly created variant X1 but i don't see the new values.
When i debug the above mentioned method, i see that for all the existing variants, the oEvent.getParameter('key') returns the variant indexs like 0,1,2,3 etc. but for the newly created variant X1, it returns the value 'sv1579082806311' and hence it doens't find it in variantset
oPersonalizationVariantSet.getVariant(sVariantKey)
and then it doesn't show the new values.
If i run the program again, i see that previously created variant X1 now shows correct values as the method oEvent.getParameter('key') returns the index and not 'sv....'. but if i now create a new variant X2, the same issue happens with X2.
I am running the App on cloud WebIDE and not on the FIORI launchpad.
Can someone help me what may be going wrong while saving the variant ?
Thanks
Br
Nilesh Puranik
I had the exact same issue recently. I assume that this is a bug in the VariantManagement control. You could create an Issue in the openui5 github project.
I also had this problem and came to the conclusion its a bug in VM control. It gives a new and long key to a newly saved variant. In the oEvent parameter "key" of your onSelect function you will see this new key.
I soved the issue by adding a new property to my JSON object I bound for variants.
In Variant Save event:
tableModel.oData.tabVariants.push({key: VariantParam.key,
text: VariantParam.name,
newKey:this.oVariant.getVariantKey()})
Then in variant select event:
var selectedKey = oEvent.getParameter("key");
var variant = this.woTableSet.getVariant(selectedKey);
if(!variant){
//In this case its a newly created variant with an internal key
//This is a workaround for the key confusion in variants
selectedKey = tableModel.oData.tabVariants.find(t => t.key ===
selectedKey).newKey;
variant = this.woTableSet.getVariant(selectedKey)
if(!variant){return} //then I give up
}
You need replace the auto generated key by variant key:
const autoGeneratedKey = oEvent.getParameters().key;
this.oContainer.save().done(function (cb) {
const oVM = that.getView().byId("vm");
oVM.replaceKey(autoGeneratedKey, that.oVariant.getVariantKey());
oVM.setInitialSelectionKey(that.oVariant.getVariantKey());
});
Related
I'm trying to set new column definitions by calling setColumnDefs using the grid API. This doesn't work as expected. The names of the column headers will not be updated anymore!
See this Plunkr: Version 19.1.x
Version 19.0.0 is latest working version.
See this Plunkr: Version 19.0.0
For me it seems to be a bug!?
In my project I'm using Angular 5 and I notice the same behaviour.
I was able to reproduce your behaviour. The following (dirty) workaround works:
gridOptions.api.setColumnDefs([]);
gridOptions.api.setColumnDefs(newColDefs);
Setting the columnDefs to an empty array and then passing the newColDefs seems to achieve what you are looking for.
I suppose it up to the new way of change-detection on the latest version.
If you will update your code like that:
function updateColDef()
{
let data = [];
columnDefs.forEach(function(colDef) {
colDef.headerName = colDef.headerName + ' X ';
data.push(colDef);
})
data.push( {
headerName: 'New Column',
});
gridOptions.api.setColumnDefs(data);
}
It will work as expected.
Update:
When new columns are set, the grid will compare with current columns and work out which columns are old (to be removed), new (new columns created) or kept (columns that remain will keep their state including position, filter and sort).
Comparison of column definitions is done on 1) object reference comparison and 2) column ID eg colDef.colId. If either the object reference matches, or the column ID matches, then the grid treats the columns as the same column.
In the first case, it was an object comparison, on the second sample (after update) its colId case.
changes came from 19.1 version release
AG-1591 Allow Delta Changes to Column Definitions.
self teaching protractor and fighting issues of non angular web app and getting the list of all values out of a select control. here is the html but can't seem to validate the list. (first weight select box at this site)
http://halls.md/body-surface-area/bsa.htm
and my failed syntax. my script executes successfully referencing the element and option but can't correctly evaluate the capture of option values in the list:
var tempstr = browser.driver.findElement(by.xpath('//select[#name="wu"]')); //get all the options
var tempstrs = tempstr.findElements(by.tagName('option'));
console.log(tempstrs[1]);
First of all, use element notation - would at least look cleaner.
If you want to see the option text or value on the console, you need to resolve promises:
var weightUnitSelect = element(by.name("wu"));
var options = weightUnitSelect.all(by.tagName("option"));
options.first().getText().then(function (text) {
console.log(text);
});
Also, I recommend to abstract select->option HTML constructions with the help of this answer:
Select -> option abstraction
I have a form called 'detail' which shows a detailed view of a selected record. The record is selected from a different form called 'search'. Because I want to be able to open multiple instances of 'detail', each showing details of a different record, I used the following code:
Public detailCollection As New Collection
Function openDetail(patID As Integer, pName As String)
'Purpose: Open an independent instance of form
Dim frm As Form
Debug.Print "ID: " & patID
'Open a new instance, show it, and set a caption.
Set frm = New Form_detail
frm.Visible = True
frm.Caption = pName
detailCollection.Add Item:=frm, Key:=CStr(frm.Hwnd)
Set frm = Nothing
End Function
PatID is the Primary Key of the record I wish to show in this new instance of 'detail.' The debug print line prints out the correct PatID, so i have it available. How do I pass it to this new instance of the form?
I tried to set the OpenArgs of the new form, but I get an error stating that OpenArgs is read only. After researching, OpenArgs can only be set by DoCmd (which won't work, because then I don't get independent instances of the form). I can find no documentation on the allowable parameters when creating a Form object. Apparently, Microsoft doesn't consider a Constructor to be a Method, at least according to the docs. How should I handle this? (plz don't tell me to set it to an invisible text box or something) Thanks guys, you guys are the best on the net at answering these questions for me. I love you all!
Source Code for the multi-instance form taken from: http://allenbrowne.com/ser-35.html
Inside your Form_detail, create a custom property.
Private mItemId As Long
Property Let ItemID(value as Long)
mItemId = value
' some code to re query Me
End Property
Property Get ItemId() As Long
ItemId = mItemId
End Property
Then, in the code that creates the form, you can do this.
Set frm = New Form_detail
frm.ItemId = patId
frm.Visible = True
frm.Caption = pName
This will allow you to pass an ID to the new form instance, and ensure it gets requeried before making it visible. No need to load all of the results every time if you're always opening the form by Newing it. You let the property load the data instead of the traditional Form_Load event.
This works because Access Form modules are nothing more than glorified classes. Hope this helps.
You could try applying a filter:
frm.Filter = "[ID] = " & patID
frm.FilterOn = True
The Record Source of the Detail form will need to be set to the table to which the ID belongs.
UPDATE
As you requested, here is the code to set the RecordSource:
frm.RecordSource = "select * from TableName where [ID] = " & patID
This is probably cleaner than using a filter given that a user can remove the filter (depending on the type of form).
After a few hours searching, I couldn't find any solution to this little problem I'm having.
I have a query that retrieves one of its criteria from a form. I have referenced correctly the value on the form from the query, and it works, but what I wanted to do is a bit more complicated: when the form is closed, I want to launch the query with a "default value".
I tried to do it in 2 different ways:
a) Defining an "IIf" at the query criteria: I would need a function that checks if the form from which I retrieve the values is open.
b) Defining public variables with a default value, which would be changed from the form: I don't know where/when to initialize the value of the variable.
Does anyone have a better idea on how to do this?
TL;DR: Query gets criteria from form when it's open. If form is closed, query uses default value. HELP!
You can create a VBA function in a module to do this :
Function MyCriterion() As Long
MyCriterion = 1234 ' default value
If CurrentProject.AllForms("MyForm").IsLoaded Then
MyCriterion = Forms("MyForm").MyControl.Value
End If
End Function
I'm using Symfony 1.2 with Doctrine. I have a Place model with translations in two languages. This Place model has also a nested set behaviour.
I'm having problems now creating a new place that belongs to another node. I've tried two options but both of them fail:
1 option
$this->mergeForm(new PlaceTranslationForm($this->object->Translation[$lang->getCurrentCulture()]));
If I merge the form, what happens is that the value of the place_id field id an array. I suppose is because it is waiting a real object with an id. If I try to set place_id='' there is another error.
2 option
$this->mergeI18n(array($lang->getCurrentCulture()));
public function mergeI18n($cultures, $decorator = null)
{
if (!$this->isI18n())
{
throw new sfException(sprintf('The model "%s" is not internationalized.', $this->getModelName()));
}
$class = $this->getI18nFormClass();
foreach ($cultures as $culture)
{
$i18nObject = $this->object->Translation[$culture];
$i18n = new $class($i18nObject);
unset($i18n['id']);
$i18n->widgetSchema['lang'] = new sfWidgetFormInputHidden();
$this->mergeForm($i18n); // pass $culture too
}
}
Now the error is:
Couldn't hydrate. Found non-unique key mapping named 'lang'.
Looking at the sql, the id is not defined; so it can't be a duplicate record (I have a unique key (id, lang))
Any idea of what can be happening?
thanks!
It looks like the issues you are having are related to embedding forms within each other, which can be tricky. You will likely need to do things in the updateObject/bind methods of the parent form to get it to pass its values correctly to its child forms.
This article is worth a read:
http://www.blogs.uni-osnabrueck.de/rotapken/2009/03/13/symfony-merge-embedded-form/comment-page-1/
It gives some good info on how embedding (and mergeing) forms work. The technique the article uses will probably work for you, but I've not used I18n in sf before, so it may well be that there is a more elegant solution built in?