I have a master-detail splitapp use for phone browser. Master page display the main list and when I click on an item, it will navigate to detail page.
The problem is, from detail page, I click on BackArrow to back to master page and tap again on the same item, onSelect event won't fire > no go anywhere. But if I tap on another item, it works.
In manifest.json, master viewlevel = 1 and detail viewlevel = 2.
Thanks
Below is the detail page navigation button
<Page
title="Title text"
showNavButton="true"
navButtonPress="onNavBack">
onNavBack function
onNavBack: function (oEvent) {
var oHistory = History.getInstance();
var sPreviousHash = oHistory.getPreviousHash();
if (sPreviousHash !== undefined) {
window.history.go(-1);
} else {
// no history handle
}}
onSelect to forward
, onSelect : function(oEvent) {
var oTransferData = this.createTransferData(oContext);
this.transferData.setData(oTransferData);
...
this.getRouter().navTo(
"detail", { ZITEM : oTransferData.ZITEM }
);
}
, createTransferData : function(oContext) {
var oData = {};
oData.ZITEM = oContext.getProperty("ZITEM");
}
the list
<List
id="masterList"
noDataText="no data"
mode="SingleSelectMaster"
selectionChange="onSelect"
includeItemInSelection="true"
>
Try itemPress event instead of select (make sure item has "Active" in its type property). It fires whenever you click on item, and select only fires when the selection changes.
You need to clear the list selection
Code
var oList = sap.ui.getCore().byId("masterList");
if(oList)
oList .removeSelections(true);
Related
My requiremnt is to put some filters on smartTable form my controller.
In Event beforeRebindTable i am using the following code to put filter using this code which is working fine.
onBeforeRebindTable: function (oEvent) {
var oBindingParams = oEvent.getParameter("bindingParams");
statFilter = new sap.ui.model.Filter("Claim_TYPE", "EQ", "1234");
oBindingParams.filters.push(statFilter);
}
But the problem is when the user is clicling on table column on filter again, the filter i am adding in above code is not visible in the selection dialog. User may need to delete this filter, If its not visible in dialog they wont be able to delete it.
I am not able to establish the link why the dialog is not getting updated, or should i add this somewhere else.
Thanks
Sonal.
onBeforeRebindTable: function (oEvent) {
var oSmartTable = oEvent.getSource();
if (this._isOnInit == null) this._isOnInit = true;
if (this._isOnInit) {
oSmartTable.applyVariant(
{
filter: {
filterItems: [{
columnKey: "YourSelectedColumn",
exclude: false,
operation: "EQ",
value1: "SomeEnteredValue",
value2: ""
}]
}
}
);
this._isOnInit = false;
}
}
I am relatively new to AEM and I am trying to hide/show dialog fields on checkbox click. I have tried some ways but failed to achieve this functionality. This is just for my own learning. How can I achieve this?
I have tried adding the js clientlib and adding some classes and target to the checkbox and target fields respectively as suggested in other answers but it didn't seem to work. Please help.
First you need to create a clientLibs and add categories as cq.authoring.dialog.all, see the code below:
(function($, $document) {
$document.on("dialog-ready", function() {
Coral.commons.ready($document, function () {
dispalyOrHideTabs();
$(document).on('change', '#showText', function() {
if($('#showText').attr('checked')){
show('1');
}else{
hide('1');
}
});
$(document).on('change', '#showTable', function() {
if($('#showTable').attr('checked')){
show('2');
}else{
hide('2');
}
});
function hide(index){
var tab = $document.find("[id='compareImgId-"+index+"']").closest(".coral3-Panel");
var tab2 = tab.attr("aria-labelledby");
var tab3 = $document.find("[id='"+tab2+"']");
tab3.addClass("hide");
}
function show(index){
var tab = $document.find("[id='compareImgId-"+index+"']").closest(".coral3-Panel");
var tab2 = tab.attr("aria-labelledby");
var tab3 = $document.find("[id='"+tab2+"']");
tab3.removeClass("hide");
}
function dispalyOrHideTabs(){
var editable = Granite.author.DialogFrame.currentDialog.editable;
if(editable){
var node = Granite.HTTP.eval(Granite.author.DialogFrame.currentDialog.editable.path + ".json");
if(node){
var storedTextValue = node.showText;
var storedTableValue = node.showTable;
if(storedTextValue){
show('1');
}else{
hide('1');
}
if(storedTableValue){
show('2');
}else{
hide('2');
}
}
}
}
});
});
})($, $(document));
Add granite:id property as showText of the checkbox resource type.
And below is the dialog tabs which will be hidden and shown:
new sap.m.Button("manualimage",{
icon : 'resources/Green.JPG',
width : "40px",
height : "40px",
press :function(e) {
var myBtn = sap.ui.getCore().byId("manualimage");
console.log(document.getElementById("manualimage").icon);
myBtn.setIcon('');
}
})
When I click on the button the Icon is not changing, any suggestions what I might be doing wrong here?
Below is my code which is working ( on UI5 version 1.42).
I only find one mistake : You should use ToggleButton to keep the state of Button. Say remove image if pressed or set image back when pressed back ( ie. not pressed).
Code in XML :
<ToggleButton icon='./images/ICICI.png' text ='hey' pressed='false' press='handlePress' />
Code in Controller:
handlePress: function(evt) {
var oSource = evt.getSource()
var bPressed = oSource.getPressed();
if(bPressed) {
oSource.setIcon('');
} else {
oSource.setIcon('./images/ICICI.png');
}
}
Let me know if this works for you.
When you use:
var myBtn = sap.ui.getCore().byId("manualimage");
your var myBtn is undefined, because using sap.ui.getCore() id of button is expecting something like:
sap.ui.getCore().byId("__xmlview1--manualimage");
where __xmlview1-- is autogenerated by framework. So please use this code instead:
var myBtn = this.byId("manualimage");
Im using the following code to display simple button,when you click on tab 2 and return to the old tab the button is removed,any idea how do put it permanent in tab1 ?
This is the controller shell
onInit: function() {
this.oViewBuffer ={};
this.oViewBuffer.btn = sap.ui.jsview("codetalk.Main");
var oShell = sap.ui.getCore().byId("main-shell");
oShell.setContent(this.oViewBuffer.btn);
},
onWorksetItemSelected:function(oEvent){
var oShell = sap.ui.getCore().byId("main-shell");
var key = oEvent.getParameter("key");
oShell.setContent(this.oViewBuffer[key]);
}
This is the JS view
createContent : function(oController) {
var oButton = new sap.ui.commons.Button({
text:"Hello Test",
tooltip:"This is toolTip",
press:function(){
alert("test alert");
}
});
return oButton;
}
This is the view of the shell
createContent : function(oController) {
var oButton = new sap.ui.ux3.NavigationItem({
key:"bth",
text:"Tab 1"
});
var oMusicStore = new sap.ui.ux3.NavigationItem({
key:"btn2",
text:"Tab 2"
});
var oShell = new sap.ui.ux3.Shell({
id:"main-shell",
appTitle:"Demo",
worksetItems:[oButton,oMusicStore],
worksetItemSelected:[oController.onWorksetItemSelected,oController]
});
return oShell;
}
first I'd recommend removing the "-" in your shell id (UI5 Dev Guide) and using camel case instead.
secondly you're calling your view with your button in the Init function but once that's done you handle your worksetItems with your controller and set the worksetItem according to your key. So far so good.
But your worksetItems aren't associated with any content so there's no reason for your shell to show you the button when you click on your first Tab
I'd recommend something like initializing your views with IDs and ste the content in your shell controller according to that id
Example:
var oViewButton = sap.ui.view("bth",{
viewName : "codetalk.Main",
type : sap.ui.core.mvc.ViewType.JS
)} //do that in your view where you define your Shell
//do the same for your view with the musicstore also in the view with the Shell
//your id of the view must match the key of your worksetItem
in your shell's controller do this:
onWorksetItemSelected : function(oEvent){
var oShell = sap.ui.getCore().byId("mainShell");
var key = oEvent.getParameter("key");
var oView = sap.ui.getCore().byId(key);
oShell.setContent(oView);
}
this solution will bypass the content aggregation of your Shell but at least it worked for me.
In shell view.js remove second last line
Example
"worksetItemSelected:[oController.onWorksetItemSelected,oController]"
It might work
I'm trying to trigger a click event that will open my href sip/tel link when user clicks the button, but it doesn't trigger the click event after the button has been pressed.
jquery code:
$('#next_button').click(function() {
var num = $(this).val();
$('#call-num'+num).trigger('click');
alert(num);
});
href code:
(999) 888-3333
<button id="next_button" value="1">Next</button>
$('#next_button').on('click', function() {
var num = $(this).val();
var call = $('#call-num'+num).attr('href');
location.href = call;
alert(call);
});