[ 3 posts ]

Bhuvana Pathsamatla

  • Username: Bhuvana
  • Joined: Mon Jun 18, 2012 2:09 am
  • Posts: 15
  • Location: India
  • IRC: Bhuvana
  • Offline
  • Profile

Issue rendering scrollable datatable in tabview

Post Posted: Mon Jun 18, 2012 9:26 pm
+1-
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 Dopazo

YUI Contributor

  • Username: jdopazo
  • Joined: Fri Oct 02, 2009 5:39 am
  • Posts: 617
  • Location: Buenos Aires, Argentina
  • Twitter: juandopazo
  • GitHub: juandopazo
  • Gists: juandopazo
  • Offline
  • Profile

Re: Issue rendering scrollable datatable in tabview

Post Posted: Tue Jun 19, 2012 7:11 am
+1-
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/

Bhuvana Pathsamatla

  • Username: Bhuvana
  • Joined: Mon Jun 18, 2012 2:09 am
  • Posts: 15
  • Location: India
  • IRC: Bhuvana
  • Offline
  • Profile

Re: Issue rendering scrollable datatable in tabview

Post Posted: Mon Jul 02, 2012 2:15 am
+0-
This worked. Thanks Juan!
  [ 3 posts ]
Display posts from previous:  Sort by  
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