Problems with adding/removing ContentPanes in AccordionContainer - dojo

I'm a complete newbie at Dojo, and Adobe AIR, which is my target. I'm
trying to put some panes into an AccordionContainer like so:
var mainview = dijit.byId("mainview");
var rand = randomString();
var widg = gtd_create_entry_widget(rand)
air.trace(mainview);
air.trace(widg);
mainview.addChild(widg);
"mainview" is my AccordionContainer, and gtd_create_entry_widget() is:
function gtd_create_entry_widget(id) {
var entry = new dijit.layout.ContentPane();
entry.attr("id",id);
entry.attr("title","title "+id);
return entry;
}
The pane shows up in the container, with the correct id and title, and
no errors, however, if I try to add another pane, the next one shows
up too, but I get the error:
TypeError: Result of expression '_7' [undefined] is not an object.
I get the same error if I run
var mainview = dijit.byId("mainview");
mainview.destroyDescendants();
and also, only one pane is destroyed at a time, and I understand this
method should destroy all the children.
I can include full project code if required.
Thanks a lot
Garry

I'm not exactly sure if this is going to fix your problem, but you're supposed to use dijit.layout.AccordianPane (http://www.dojotoolkit.org/api/dijit/layout/AccordionPane.html) with the AccordianContainer.

Related

vuejs: mounted issues with coordinates of elements and svg

I have three columns, two with divs and the central one with an svg. I made a method that calculate the top() of each paragraph inside the divs to get the position and then draw an arrow in the svg. The problem is that when I use that method the first time I open my component, I get all zeroes, probably because the paragraph aren't really drawn (they have no coordinates) yet. I tried in mounted(), which should be the right place to do that. I use it also in updated() in case I reload my json with new data.
Am I missing something trivial?
The code I use to get the coordinates is like this:
drawLine(index1, index2) {
//var plist1 = this.$refs['p_list1'];
//var plist2 = this.$refs['p_list2'];
var plist1 = document.getElementsByClassName('p_list1');
var plist2 = document.getElementsByClassName('p_list2');
if (plist1.length == 0 && plist2.length == 0) return;
var svg = document.createElementNS('http://www.w3.org/2000/svg', 'line');
//...
//const start = this.$refs['startpos'].getBoundingClientRect().top;
const start = document.getElementById('startpos').getBoundingClientRect().top;
const r1 = plist1[index1].getBoundingClientRect();
const r2 = plist2[index2].getBoundingClientRect();
index1 and index2 comes from a loop where I get which paragraph I have to connect with an arrow (also where the nextThick is)
Here is a simple example of the issue:
https://codesandbox.io/s/bootstrap-vue-test-bcozc
Note: it's badly shown, but if you press "DO" and then switch tab, you'll see that the arrow aren't correct. If you switch tab and then press DO, it will work.
Put your calculation methods in a $nextTick function to allow parents and children to fully render.
If that does not work, as a debug step, try using a setTimeout method to delay the calculation.
After understanding that the problem was linked to how tabs are built, I tried making that specific tab lazy and it worked.
<b-tab lazy ...
I don't know how tabs are normally built, but I suppose the dom is put together without having a real coordinate system and when it's made visible, I don't have any event to read to update the svg.

How to add an ImgButton in ListGridRecord and set it to DataSourceField?

I have a DataSource class that extends com.smartgwt.client.data.DataSource. I have several DataSourceTextFields in it that show some Strings, and I need to also show an image button in one of the columns. The problem is that if I add another field like that:
DataSourceField icon = new DataSourceField("name", FieldType.ANY, "title");
setFields(/*the other fields*/, icon);
and then upon Fetch I add all values like that:
ArrayList<Record> records = new ArrayList<Record>();
// add all records in iteration, an then add the icon one
ListGridRecord iconRecord = new ListGridRecord();
ImgButton icon = new ImgButton();
icon.setSrc("theSrc/icon.png");
// icon.addClickHandler to execute some action
iconRecord.setAttribute("name", icon);
records.add(iconRecord);
response.setData(records.toArray(new Record[records.size()]));
processResponse(requestId, response);
All of this produces a com.google.gwt.core.client.JavaScriptException: (null): null - the table shows, but with empty rows and with this error in the Console (with no more details).
I also tried to put the ImgButton in a HLayout, but I get the same error. I also tried to create a DataSourceImageField for the purpose, but then I have other errors.
Could you, please, help?
Thank you.

programmatic view transition in dojo mobile

I would like to perform a programmatic view transition.
Here is a code I've tried :
var v = registry.byId('myenergy-pane');
v.transitionTo("home-pane");
Here is another one
var v = registry.byId('myenergy-pane');
v.performTransition("home-pane",1,"slide",null);
None of them is working.
Thanks for your help.
The second code you provided should work, but that's considering the following facts:
The code is executed after the DOM is loaded and the views are parsed by the dojo/parser. The correct way to indicate that is by using dojo/ready, for example:
require(["dojo/ready"], function(ready) {
var v = registry.byId('myenergy-pane');
v.performTransition("home-pane", 1, "slide", null);
});
Both given IDs (myenergy-pane and home-pane) are related to a widget (not only a DOM node) and are both views (dojox/mobile/View or inheriting from).
Make sure you are loading dijit/registry and the registry module alias is actually mapped to the correct module.
I also made a JSFiddle to demonstrate that it should be working: http://jsfiddle.net/g00glen00b/3JMnC/

on(release) {...} or myButton.onRelease = function() {...} - action script 2 issues

I am having real confusion with some flash banners I'm creating and making the button into a clickable object which opens a web page.
I have been using this code for a while below, which works...
on(release){
getURL("http://www.the-dude.co.uk", "_blank");
}
And I placed this code on actual button within the actions panel
However I have been told the code above is very old and that I should use action script like below...
buttonInstance.onRelease = function() {
getURL("http://www.the-dude.co.uk", "_blank");
}
So I've tried to get this method below to work but nothing happens when I click the button, and I get one error, this...
So in a nutshell I cannot get this newer code to work! Ahh
Can anyone please help me understand where I am going wrong?
I have tried placing the new code in the Scene 1 of my actions. No worky..
And I've also tried placing the code below, actually on my button within the actions panel...
this.onRelease = function() {
getURL("http://www.the-dude.co.uk", "_blank");
}
Still not working.
My scene settings are alway this...
Any help would be great thanks.
You need to place the code below on the same timeline as the instance of the button (as you tried). And the instancename of the button must be "buttonInstance".
You can set the instance name in the properties panel when the button is selected.
buttonInstance.onRelease = function() {
getURL("http://www.the-dude.co.uk", "_blank");
}

"The specified view is invalid" in call to LimitedWebPartManager.AddWebPart in SharePoint 2010

This code used to work in WSS 3.0 / MOSS 2007 in FeatureReceiver.FeatureActivated:
using (SPLimitedWebPartManager limitedWebPartManager = Site.GetLimitedWebPartManager("default.aspx", PersonalizationScope.Shared)) {
ListViewWebPart listViewWebPart = new ListViewWebPart {
Title = title,
ListName = list.ID.ToString("B").ToUpper(),
ViewGuid = view.ID.ToString("B").ToUpper()
};
limitedWebPartManager.AddWebPart(listViewWebPart, zone, position);
}
I'm trying to convert to SharePoint 2010 and it now fails with:
System.ArgumentException: The specified view is invalid.
at Microsoft.SharePoint.SPViewCollection.get_Item(Guid guid)
at Microsoft.SharePoint.WebPartPages.ListViewWebPart.EnsureListAndView(Boolean requireFullBlownViewSchema)
at Microsoft.SharePoint.WebPartPages.ListViewWebPart.get_AppropriateBaseViewId()
at Microsoft.SharePoint.WebPartPages.SPWebPartManager.AddWebPartInternal(SPSupersetWebPart superset, Boolean throwIfLocked)
at Microsoft.SharePoint.WebPartPages.SPLimitedWebPartManager.AddWebPartInternal(WebPart webPart, String zoneId, Int32 zoneIndex, Boolean throwIfLocked)
at Microsoft.SharePoint.WebPartPages.SPLimitedWebPartManager.AddWebPart(WebPart webPart, String zoneId, Int32 zoneIndex)
Interestingly enough when I run it from a unit test it works, it only fails in FeatureActivated. When I debug with Reflector it is failing on this line:
this.view = this.list.LightweightViews[new Guid(this.ViewGuid)];
list.LightweightViews only returns one view, the default view, even though list.Views returns all of them. When running from a unit test LightweightViews returns all of my views. I have no idea what LightweightViews is supposed to mean and I'm running out of ideas. Anyone else got any?
To make it work, just do the following:
Do not set the viewguid property of the listviewwebpart object (leave it blank)
call the AddWebpart method
It will generate a new viewguid associated to a new hidden view.
Then if you want to customize this view, retrieve it from the list and customize it.
Hopefully no one ever has this problem or even sees this question. In the unfortunate event you get the same problem I have no specific solution. It eventually just started to work for me (8 hour later). I can tell you what I did right before it started working and hopefully it will help:
I went in through the UI and set the view that I was trying to set the list view web part to as the default view. I believe that's what fixed it and I have no idea why.
Some other notes on the problem:
I create all my lists and views through code
RunWithElevatedPrivileges did not help
Instantiating a new SPWeb in feature activated did not help
Setting ListViewXml = view.HtmlSchemaXml instead of setting ViewGuid made it not crash but the view was wrong when this code executed in FeatureActivated but correct when executed in a unit test.
Best I can do, sorry. If you're having this problem, good luck!
After reading this and this articles I found even more easiest solution.
When you add listviewwebpart to an any page, webpart automatically creates new hidden view in list, which is associated with this webpart (you can check it in SharePoint Manager).
When you switch view for listviewwebpart throw UI, it simply get copy of fields from selected view and push it in his hidden view.
All you need is get this view by ID, add\remove necessary fields and update view. Something like this:
var wpMngr = web.GetLimitedWebPartManager(workspaceWeb.Url + "/default.aspx", PersonalizationScope.Shared);
var attendeeListViewWebPart =
(ListViewWebPart)wpMngr.WebParts.Cast<WebPart>().FirstOrDefault(w => w.Title == Lists.AttendeesList);
var list = workspaceWeb.Lists[Lists.AttendeesList];
var view = list.Views.Cast<SPView>().FirstOrDefault(w => w.ID.ToString("B").Equals(attendeeListViewWebPart.ViewGuid, StringComparison.OrdinalIgnoreCase));
view.ViewFields.DeleteAll();
view.ViewFields.Add...
view.Update();
According to articles, you cann't update ViewGuid property for listviewwebpart.
I have been fighting with this today also.
For some odd reasons the code that you provided works for some cases but not in others.
I haven't had time to investigate more about that but what I can say is that if you are willing to use the XsltListViewWebPart (which is the replacement of the ListViewWebPart in SharePoint 2010), you will get rid of this annoying "bug".
I have just tested in myself.
Hope it helps!
I was getting this same error with an XsltListViewWebPart:
Exception: System.ArgumentException: The specified view is invalid.
at Microsoft.SharePoint.SPViewCollection.get_Item(Guid guid)
at Microsoft.SharePoint.SPList.GetView(Guid viewGuid)
at Microsoft.SharePoint.SPList.GetView(String viewGuid)
at Microsoft.SharePoint.WebPartPages.BaseXsltListWebPart.EnsureView()
at Microsoft.SharePoint.WebPartPages.BaseXsltListWebPart.get_AppropriateBaseViewId()
at Microsoft.SharePoint.WebPartPages.SPWebPartManager.AddWebPartInternal(SPSupersetWebPart superset, Boolean throwIfLocked)
at Microsoft.SharePoint.WebPartPages.SPLimitedWebPartManager.AddWebPartInternal(WebPart webPart, String zoneId, Int32 zoneIndex, Boolean throwIfLocked)
at Microsoft.SharePoint.WebPartPages.SPLimitedWebPartManager.AddWebPart(WebPart webPart, String zoneId, Int32 zoneIndex)
Since SPList.GetView is a public method, I tried it in Powershell using the Guid from my new view. It worked fine.
I figured out that the problem was the context. I had been creating my view right before the ViewGuid assignment. When I moved the creation of my view outside of the SPLimitedWebPartManager, the code ran without any errors:
SPView view = CreateHiddenView(list);
using (SPLimitedWebPartManager manager = file.GetLimitedWebPartManager(PersonalizationScope.Shared))
{
try
{
XsltListViewWebPart webpart = new XsltListViewWebPart();
webpart.ListName = list.ID.ToString("B").ToUpperInvariant();
webpart.TitleUrl = list.DefaultViewUrl;
webpart.WebId = list.ParentWeb.ID;
webpart.Title = list.Title;
webpart.ViewGuid = view.ID.ToString("B").ToUpperInvariant();
manager.AddWebPart(webpart, "Right", 1);
}
finally
{
manager.Web.Dispose();
}
}