Dijit Tabcontainer inside a custom widget-Tablist

2019-06-26 03:13发布

I have a templated custom widget that inherits from dijit.layout._LayoutWidget, dijit._Container, and dijit._Templated which gives my widget native Widget support for resizing, etc. All I need is a TabContainer, which is sized to the size of widget. Here is my widget.

<div dojoAttachPoint="containerNode">
    <div dojoType="dijit.layout.TabContainer" tabPosition="top" style="width:100%;height:100%" >
    <div dojoType="dijit.layout.ContentPane" title="tab" selected="true">
    hello
    </div>
</div>
</div>

Everything looks fine but I get a weird TabList.This is what I get!

I looked into the problem. All the pieces of the widget and TabContainer have the correct width and height values. Only The tablist has a loooong width (50'000 something pixels wide): I have read about similar issues such as this one: http://bugs.dojotoolkit.org/ticket/10495, but in my case all the elements have correct width and length. I have no idea how does tablist get this long width.

I have also tried many ways of adding and removing style="width:100%;height:100;" for the parent container and its parents. But none of the configurations fixed the problem.

Is there a way to fix this problem?

4条回答
Anthone
2楼-- · 2019-06-26 03:47

Just rewrite your css like this:

div[class="dijitTabListWrapper dijitTabContainerTopNone dijitAlignClient"]{
  height: 30px !important;
}

@-moz-document url-prefix() {
  div[class="dijitTabListWrapper dijitTabContainerTopNone dijitAlignClient"]{
    height: 31px !important;
  }
}
查看更多
叼着烟拽天下
3楼-- · 2019-06-26 03:48

If you want to remove the first one : "useMenu : false" If you want to remove the second and the third : "useSlider : false"

查看更多
Evening l夕情丶
4楼-- · 2019-06-26 03:50

Just in case someone is looking for the solution, I had the same problem, and came to this question. Though I looked at the bug reports, it didn't apply in my case, I was not embedding tabcontainer inside table or setting doLayout to false. I tried setting tabcontroller but that didn't work either. Finally after debuggin, turns out you have to provide 'resize' method in your widget and resize tabcontainer inside it in the following way

widgetTemplate =  '... ' + //Our tabcontainer declaration
'<div dojoAttachPoint="containerNode">' +
'<div dojoAttachPoint="widgetTab" dojoType="dijit.layout.TabContainer"' + 'style="width:100%;height:100%" >' +
'<div dojoType="dijit.layout.ContentPane" title="tab" selected="true">hello</div></div></div>' + 
'...' //Rest Of template declaration

//Since we are embedding widget inside template we need _WidgetsInTemplateMixin
dojo.declare("MyWidget", [dijit._Widget, dijit._TemplatedMixin,dijit._WidgetsInTemplateMixin], {
templateString: widgetTemplate,
.... //Rest of functions
resize: function(){
this.containerNode.widgetTab.resize() //Resize tabcontainer 
}

});

Hope this helps

查看更多
贪生不怕死
5楼-- · 2019-06-26 04:12

Try to add attribute to your TabContainer:

<div dojoType="dijit.layout.TabContainer" controllerWidget="dijit.layout.TabController" ... >

http://bugs.dojotoolkit.org/ticket/10113#comment:11

查看更多
登录 后发表回答