| Page 1 of 1 | [ 3 posts ] |
|
I am using YUI 3.5.1 and I am still facing the issue to display scrollable datatable in a tabview. The table width is almost invisible when the tab containing the datatable is clicked. It is set to correct width only when the sort is clicked on the only column which is displayed.
I referred to the other topics in the forum which mentions that the issue is fixed but I am still facing the issue in 3.5.1. I am pasting some of the code snippets here for better understanding. I render the tabview after rendering the table and I am not sure if this is causing the issue in any way. TabView: <div id="hometabs"> <ul> <li><a href="#Login">Home</a></li> <li><a href="#Submission">Submission</a></li> <li><a href="#Reports">Reports</a></li> <li><a href="#Ranking">Ranking</a></li> <li><a href="#Admin">Admin</a></li> </ul> <div class="themebackground" style="background-color:#FFFFFF"> <div id="Login"><jsp:include page="logincontents.jsp" /></div> <div id="Submission"><jsp:include page="displaycontacts.jsp" /></div> <div id="Reports">Reports content</div> <div id="Ranking">Ranking content</div> <div id="Admin"><jsp:include page="admininput.jsp" /></div> </div> </div> <script> YUI().use('tabview', function(Y) { var tabview = new Y.TabView({ srcNode: '#hometabs' }); tabview.render(); }); </script> Datatable:(The code below is present in displaycontacts.jsp which is included in submissions tab) <div id="basic"> </div> <script> YUI().use("datatable-sort","datatable-column-widths","datatable-scroll","datasource","datasource-get", "datasource-jsonschema","datasource-io","datatable-datasource", function(Y) { var table = new Y.DataTable({ columns: [{key:"firstName", label:"First Name", sortable:true}, {key:"lastName", label:"Last Name", sortable:true}, {key:"companyName", label:"Company Name", sortable:true}, {key:"position", label:"Position", sortable:true}, {key:"email", label:"Email", sortable:true}, {key:"telephone", label:"Telephone", sortable:true}, {key:"selectcontact", label:"Interviewed",allowHTML: true, formatter: '<input type="drop-down list"/>',emptyCellValue: '<label for="field-3"></label><select id="field-3" name="field-3"><option value="1">Yes</option><option value="2">No</option></select>'}, {key:"selectcontact", label:'<input name="contentBox" type="checkbox" class="protocol-select-all" />',allowHTML: true, formatter: '<input type="checkbox" checked/>',emptyCellValue: '<input type="checkbox"/>'} ], // and/or a summary (table attribute) summary: "Example DataTable showing basic instantiation configuration", width: '100%', scrollable: 'y' }); table.plug(Y.Plugin.DataTableScroll, {height:"300px"}); table.plug(Y.Plugin.DataTableDataSource, { datasource: myDataSource }); table.render("#basic"); table.datasource.load(); }); </script> |
Juan Ignacio DopazoYUI Contributor
|
Like other widgets, Scrolling Datatables need to do calculations based on the size of the container to adjust the size or position of some inner elements. If the node in which they render is hidden, they can't do those calculations and so they look broken. That's why your table looks like it has a collapsed width. I wrote a broken example here: http://jsfiddle.net/juandopazo/H2ASR/.
The way to avoid this is to wait until the tab that will hold the datatable is shown. You can do that by listening to the "after" stage of the "selectedChange" event of the Tab. For example: Code: tabview.item(1).after('selectedChange', function (e) { if (e.newVal) { table.render(this.get('panelNode')); } }); Here's the fixed complete example: http://jsfiddle.net/juandopazo/H2ASR/2/ |
|
This worked. Thanks Juan!
|
| Page 1 of 1 | [ 3 posts ] |
| You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum |
© 2006-2013 Yahoo! Inc. All rights reserved.
All code on this site is licensed under the BSD License unless stated otherwise.
About This Site · Security Contact Info
Powered by phpBB® Forum Software © phpBB Group