Need simple example: add tabs to widget

7040
57
Jump to solution
01-19-2018 08:44 AM
JamesCrandall
MVP Frequent Contributor

LaunchPad theme

WABDev 2.5

Custom Widget

I'm looking for the simplest, most straight forward example of adding 2 tabs to a new widget (an absolute vanilla panel).  THIS thread seemed to be close but I'm not seeing the expected result (no CSS example?). 

Looking for the most basic form of HTML, JS and CSS to get this implemented.

TIA

0 Kudos
57 Replies
RobertScheitlin__GISP
MVP Emeritus

Try setting the disabled on the pane as one of those other suggestions states

registry.byId('step2').set('disabled', true);

0 Kudos
Arne_Gelfert
Regular Contributor

Darn - I've tried so many variations of this:

init.js:115 TypeError: registry.byId(...).set is not a function

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Arne,

   That tells me that it did not find the contentpane by the id then.  What function in your code are you putting this in (i.e. widget lifecycle, Startup, postCreate, etc, etc)?

0 Kudos
Arne_Gelfert
Regular Contributor

So instead of using what I thought would be the id set in my div, I found in Dev Tools that it's actually something different. The following at least gives me a reference...

registry.byId('dijit_layout_ContentPane_1')

//  but

registry.byId('dijit_layout_ContentPane_1').set('disabled',true);

// does nothing

If I try what has been suggested elsewhere, e.g. here, I get an error:

dojo.style(registry.byId('dijit_layout_ContentPane_1').controlButton.domNode,{display:"none"});
dojo.style(registry.byId('dijit_layout_ContentPane_1').controlButton.domNode,{display:"inline-block"});

>>TypeError: Cannot read property 'domNode' of undefined

What is this controlButton property? Why is it not available?

0 Kudos
Arne_Gelfert
Regular Contributor

Regarding your question where all this is created... it's all happening in my postcreate() function.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

postcreate is probably to early in the widget life cycle for this. I am not sure if all the widgets dom element would be created and rendered inside that function. The controlButton property would be the actual tab in the tab controller.

0 Kudos
Arne_Gelfert
Regular Contributor

Interesting.... let me try and move it to startup(). -- Any useful guidance as to what elements of your code should live where in the lifecycle? I have often wonder. I figured that many of not most of my function, especially if they don't really interact with DOM and layout could be defined early. I once had some event handlers living in open() and was told you'd end up with a bunch new ones each time that widget was opened, which could lead to memory leaks. But still I never really have though about it further. Maybe stuff for another post. Let me try what you suggested.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Widget life cycle—ArcGIS Web AppBuilder (Developer Edition) | ArcGIS for Developers 

Creating event handlers in in the onOpen is definitely a bad idea. Unless you are first checking if the event handler exists and then removing it before creation. 

0 Kudos
Arne_Gelfert
Regular Contributor

I know, I know... I did that months ago - about the time you started answering my first helpless cries for expertise. I've learned a few tricks since then. That ESRI page is alright. As usual, they could do better though.

0 Kudos
Arne_Gelfert
Regular Contributor

Okay, so I realized that I had it in startup()... no idea what's going here. But I really don't think I have the time to code around all these dojo quirks. Dojo seems to get in the way of getting stuff done all the time. I'll go back to trying a basic n HTML/css tab container.

0 Kudos