I read in the Primefaces forum that updating dialogs in direct way or updating encircling elements should be avoided since the instances are duplicated and other strange behaviours.
But we have some kind of a special case and would really need to update an element that contains lot of dialogs.
Is there really no way to do this in a same way without getting duplicated instances? How does it come to the duplicated instances? Could it be that this only happens when appendToBody is set to true because it is updated and shifted once more to the body instead of just being updated?
A solution is to fix the dialog.js, see Primefaces forum.
For Primefaces 3.4.1:
PrimeFaces.widget.Dialog.prototype._show = function() {
if(this.cfg.showEffect) {
var _self = this;
this.jq.show(this.cfg.showEffect, null, 'normal', function() {
_self.postShow();
});
}
else {
//display dialog
/*Begin Custom Code*/
var dlg = jQuery(this.jqId);
if(dlg.size() > 1){
dlg.last().remove();
}
this.jq = dlg;
/*End Custom Code*/
this.jq.show();
this.postShow();
}
this.focusFirstInput();
this.visible = true;
this.moveToTop();
if(this.cfg.modal)
this.enableModality();
}
The dialog was reimplemented in v3.0. I think there are no problems now.
For Primefaces 3.5
PrimeFaces.widget.Dialog.prototype._show = function() {
this.jq.removeClass("ui-overlay-hidden").addClass("ui-overlay-visible").css({display:"none",visibility:"visible"});
if(this.cfg.showEffect){
var a=this;
this.jq.show(this.cfg.showEffect,null,"normal",function(){
a.postShow();
});
}
else {
//display dialog
/*Begin Custom Code*/
var dlg = jQuery(this.jqId);
if(dlg.size() > 1){
dlg.first().remove();
}
this.jq = dlg;
/*End Custom Code*/
this.jq.show();
this.postShow();
}
this.moveToTop();
if(this.cfg.modal){
this.enableModality();
}
}
Related
I have a modal Navigation page with an image which acts like a button;
<Image Source ="share.png" HeightRequest="32" WidthRequest="32">
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="On_Share" />
</Image.GestureRecognizers>
</Image>
And the method behind;
async void On_Share(object sender, EventArgs e)
{
if (CrossConnectivity.Current.IsConnected)
{
var message = "Share this";
var title = "Share";
await CrossShare.Current.Share(new ShareMessage { Text = message, Title = title}, new ShareOptions { ExcludedUIActivityTypes = new[] { ShareUIActivityType.PostToFacebook } });
}
else
{
NoInternetLabel.IsVisible = true;
}
}
I'm getting the error when I try to click on the share image/button. I've put breakpoints into the first line of the On_Share method & they're not being hit.
Warning: Attempt to present <UIActivityViewController: 0x141b60f70> on <Xamarin_Forms_Platform_iOS_ModalWrapper: 0x1419a0920> whose view is not in the window hierarchy!
Please note this works fine in Android, I'm only seeing issues in iOS. I'm not sure what is going on - I'm not trying to present any other windows or anything when I click the image. Regardless, the error appears before the process reaches the beginning of the On_Share method. What am I missing here?
EDIT: The method does get hit now, and I'm still getting the error. It must be trying to send up the share sheet and failing...
There was a problem with the Share plugin in the end - we resolved it by making part of the code recursive.
the GetVisibleViewController used to look like this;
UIViewController GetVisibleViewController()
{
var rootController = UIApplication.SharedApplication.KeyWindow.RootViewController;
if (rootController.PresentedViewController == null)
return rootController;
if (rootController.PresentedViewController is UINavigationController)
{
return ((UINavigationController)rootController.PresentedViewController).VisibleViewController;
}
if (rootController.PresentedViewController is UITabBarController)
{
return ((UITabBarController)rootController.PresentedViewController).SelectedViewController;
}
return rootController.PresentedViewController;
}
whereas it needed to cycle through to find the top UIViewController;
UIViewController GetVisibleViewController(UIViewController controller = null)
{
controller = controller ?? UIApplication.SharedApplication.KeyWindow.RootViewController;
if (controller.PresentedViewController == null)
return controller;
if (controller.PresentedViewController is UINavigationController)
{
return ((UINavigationController)controller.PresentedViewController).VisibleViewController;
}
if (controller.PresentedViewController is UITabBarController)
{
return ((UITabBarController)controller.PresentedViewController).SelectedViewController;
}
return GetVisibleViewController(controller.PresentedViewController);
}
I've raised the issue and submitted a pull request on the github
I am developing an app where I have come across at the condition where I am fetching some links from database, based on those links more retrieval is being done. I want to disable the outputlink if there is an empty row retrieved based on this outputlink.
I am swtting preRequisiteNull with boolean result and rendering the outputlink in primefaces but it disappear when if only one row have true value.
My Code:
for(LabOrdersDTO laborderDto:labOrdersDTOListDataModel.getWrappedData())
{
System.out.println("Speciman Name"+laborderDto.getTest());
System.out.println(laborderDto.getLabNo());
for(LabOrdersDTO laborderDto2:labTestPreReqList.getWrappedData())
{
System.out.println("Lab test"+laborderDto2.getTest());
if(laborderDto2.getTestPreReq()!=null){
preRequisiteNull = false;
}else{
preRequisiteNull = true;
}
}
}
if i understand you correctly, then your mistake is in your for-loops.
you want to disable link if one link = null ? right?
if yes then you have to breake the loop if one link is null, otherwise the next notNull link will override the value.
replace this:
for(LabOrdersDTO laborderDto:labOrdersDTOListDataModel.getWrappedData())
{
for(LabOrdersDTO laborderDto2:labTestPreReqList.getWrappedData())
{
if(laborderDto2.getTestPreReq()!=null){
preRequisiteNull = false;
}else{
preRequisiteNull = true;
}
}
}
width this :
for(LabOrdersDTO laborderDto:labOrdersDTOListDataModel.getWrappedData())
{
for(LabOrdersDTO laborderDto2:labTestPreReqList.getWrappedData())
{
if(laborderDto2.getTestPreReq()==null){
preRequisiteNull = true;
// update the link state or no idea how you manage it to disable the link
break;
}
}
}
BUT i cannot see how you set the link state to be disabled. my suggestion will break if one row is empty, but you have to update the state of that link!
I need to load more items as soon as the user scroll to the end of my list view.
I tried to use the microsoft sample : http://code.msdn.microsoft.com/windowsapps/ListView-loading-behaviors-718a4673/view/SourceCode (scenario 2) but it seams that list view have not the same behavior in windows phone 8.1.
When I run the sample I can see that only viewable contents are loaded (eg 5items of 50).
But for windows phone it does load all items.
I use this code :
listView.winControl.itemTemplate = this.incrementalTemplate;
incrementalTemplate: function (itemPromise, recycledElement) {
if (!recycledElement) {
recycledElement = document.createElement('div');
}
var renderComplete = itemPromise.then(function (item) {
console.log(item.index);
itemTemplate.winControl.render(item.data, recycledElement);
return item.ready;
}).done(function (item) {
console.log("clp"+item.index);
});
return { element: recycledElement, renderComplete: renderComplete };
},
Items are loaded asynchronusly. I can see in my console that it print 50 times the index and 50times the clp+index. Even if my list just show 5 items at a time.
Also it seems that my listview never fired the loading state event
listView.addEventListener("loadingstatechanged", function (args) {
//never fired
}, false);
The listview is in a hub, the solution was to add an onscroll event on the win pivot item:
document.querySelector(".win-pivot-item-content").onscroll = function () {
if (self.scrollAtBottom(this) === true) {
//load more
}
};
scrollAtBottom : function(element){
return element.scrollHeight - element.scrollTop === element.clientHeight
},
If you want to subscribe to event when the ListView was scrolled, you can take ListView's Scrollviewer and subscribe to ViewChanged event. The only problem is that I do not know how it would look like in winjs, in C# it can look like that:
// method to pull out a ScrollViewer
public static ScrollViewer GetScrollViewer(DependencyObject depObj)
{
if (depObj is ScrollViewer) return depObj as ScrollViewer;
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++)
{
var child = VisualTreeHelper.GetChild(depObj, i);
var result = GetScrollViewer(child);
if (result != null) return result;
}
return null;
}
// subscription:
GetScrollViewer(yourListView).ViewChanged += yourEvent_ViewChanged;
Maybe it will help.
The comment voted here as solution does not work just like that out the box, however I found a solution to this problem starting from that.
See my first answer on the issue I opened at https://github.com/winjs/winjs/issues/690#issuecomment-61637832 (includes code snippet)
I am binding form fields value using knockout foreach binding which uses the value retrived from database & that work fine. but how to use this foreach binding to clear same form which i binding through knockout foreach binding? how to achive this?
You can use the pattern described in this blog post: http://www.knockmeout.net/2013/01/simple-editor-pattern-knockout-js.html
var Item = function(data) {
this.name = ko.observable();
this.price = ko.observable();
this.cache = function() {};
this.update(data);
};
ko.utils.extend(Item.prototype, {
update: function(data) {
this.name(data.name || "new item");
this.price(data.price || 0);
//save off the latest data for later use
this.cache.latestData = data;
},
revert: function() {
this.update(this.cache.latestData);
}
});
Now you can bind the cancel buttons click event to the revert method.
I have been dropped into a sharepoint 2007 project, and i have relatively little experience with altering existing webparts.
My first task is to add a filter to two out of three columns in a list view. My Lead Dev suggests trying to add a jquery combo-box filter, and another dev suggests extending the web part and overriding some of the functionality.
What i think is a good option is to change the context menu for the list view headers, so that instead of "Show Filter Choices" bringing up a standard dropdownlist that only responds to the first letter, it would have a jquery combobox. And maybe if the business requests it, change the wording of that option.
My question to you is, what would be a good path to take on this? Also, what resources are there besides traipsing around books and blogs are there to guide an sp newbie to do this?
Thanks.
How about something like this:
<script src="http://www.google.com/jsapi"></script>
<script>
google.load("jquery", "1.2.6");
google.setOnLoadCallback(function() {
$(document).ready(function()
{
jQuery.extend(jQuery.expr[':'], {
containsIgnoreCase: "(a.textContent||a.innerText||jQuery(a).text()||'').toLowerCase().indexOf((m[3]||'').toLowerCase())>=0"
});
$("table.ms-listviewtable tr.ms-viewheadertr").each(function()
{
if($("td.ms-vh-group", this).size() > 0)
{
return;
}
var tdset = "";
var colIndex = 0;
$(this).children("th,td").each(function()
{
if($(this).hasClass("ms-vh-icon"))
{
// attachment
tdset += "<td></td>";
}
else
{
// filterable
tdset += "<td><input type='text' class='vossers-filterfield' filtercolindex='" + colIndex + "' /></td>";
}
colIndex++;
});
var tr = "<tr class='vossers-filterrow'>" + tdset + "</tr>";
$(tr).insertAfter(this);
});
$("input.vossers-filterfield")
.css("border", "1px solid #7f9db9")
.css("width", "100%")
.css("margin", "2px")
.css("padding", "2px")
.keyup(function()
{
var inputClosure = this;
if(window.VossersFilterTimeoutHandle)
{
clearTimeout(window.VossersFilterTimeoutHandle);
}
window.VossersFilterTimeoutHandle = setTimeout(function()
{
var filterValues = new Array();
$("input.vossers-filterfield", $(inputClosure).parents("tr:first")).each(function()
{
if($(this).val() != "")
{
filterValues[$(this).attr("filtercolindex")] = $(this).val();
}
});
$(inputClosure).parents("tr.vossers-filterrow").nextAll("tr").each(function()
{
var mismatch = false;
$(this).children("td").each(function(colIndex)
{
if(mismatch) return;
if(filterValues[colIndex])
{
var val = filterValues[colIndex];
// replace double quote character with 2 instances of itself
val = val.replace(/"/g, String.fromCharCode(34) + String.fromCharCode(34));
if($(this).is(":not(:containsIgnoreCase('" + val + "'))"))
{
mismatch = true;
}
}
});
if(mismatch)
{
$(this).hide();
}
else
{
$(this).show();
}
});
}, 250);
});
});
});
It will need to be added to the page via a content editor web part.