views:

363

answers:

1

Im fairly new to jquery and Im using jquery tools for tabs. I am wanting in one of the tabs to show flexigrid, but when I try to do this flexigrid does not show up, its just blank. If I setup flexigrid in a stand alone page outside the tab it works just fine. Below is the code that isnt working. Again Im new so please go easy!

    <ul class="css-tabs">
      <li><a href="#details">Account Details</a></li>
      <li><a href="#accounts">Sub Accounts</a></li>
      <li><a href="#groups">Groups</a></li>
      <li><a href="#support">Tickets</a></li>
    </ul>

    <div class="css-panes">
      <div>Tab 1</div>
      <div><table id="flex1" style="display:none"></table></div>
      <div>Tab 3</div>
      <div>Tab 4</div>
    </div>

     <script>
$(function() {
$("ul.css-tabs").tabs("div.css-panes > div").history();
});

$('.flexme1').flexigrid();
$('.flexme2').flexigrid({height:'auto',striped:false});

$("#flex1").flexigrid
(
{
url: '/accounts_list.php',
dataType: 'json',
colModel : [
{display: 'ID', name : 'id', width : 45, sortable : true, align: 'center'},
{display: 'Username', name : 'username', width : 120, sortable : true, align: 'left'},
{display: 'Display Name', name : 'displayname', width : 150, sortable : true, align: 'left'},
{display: 'Limit', name : 'accounts', width : 50, sortable : true, align: 'center'},
{display: 'Rate', name : 'charge', width : 50, sortable : true, align: 'center'},
{display: 'Subs', name : 'subcount', width : 50, sortable : true, align: 'center'}
],
searchitems : [
{display: 'ID', name : 'id'},
{display: 'Username', name : 'username', isdefault: true},
{display: 'Display Name', name : 'displayname'}
],
sortname: "id",
sortorder: "desc",
usepager: true,
singleSelect: true,
title: 'Test',
useRp: true,
rp: 20,
showTableToggleBtn: false,
width: 500,
height: 250
});
     </script>
A: 

I didn't find any trouble when using them both.

<!-- Here are the tabs -->
<ul class="css-tabs">
  <li><a href="#details">Account Details</a></li>
  <li><a href="#accounts">Sub Accounts</a></li>
  <li><a href="#groups">Groups</a></li>
  <li><a href="#support">Tickets</a></li>
</ul>

<!-- Here is the tab's content -->
<div class="css-tabs">
  <div>Tab 1</div>
  <div><table id="flex1" style="display:none"></table></div>
  <div>Tab 3</div>
  <div>Tab 4</div>
</div>

<script type="text/javascript">
   // On DOM ready,
   $(function() {
      // Setup the tabs.
      $("ul.css-tabs").tabs("div.css-panes > div").history(); 

      //Setup the Table
      $("#flex1").flexigrid({
         // Make sure, you are pointing to the right page. NO 404.
         url: '/accounts_list.php',
         dataType: 'json',
         colModel : [
           {display: 'ID', name : 'id', width : 45, sortable : true, align: 'center'},
           {display: 'Username', name : 'username', width : 120, sortable : true, align: 'left'},
           {display: 'Display Name', name : 'displayname', width : 150, sortable : true, align: 'left'},
           {display: 'Limit', name : 'accounts', width : 50, sortable : true, align: 'center'},
           {display: 'Rate', name : 'charge', width : 50, sortable : true, align: 'center'},
           {display: 'Subs', name : 'subcount', width : 50, sortable : true, align: 'center'}
         ],
         searchitems : [
           {display: 'ID', name : 'id'},
           {display: 'Username', name : 'username', isdefault: true},
           {display: 'Display Name', name : 'displayname'}
         ],
         sortname: "id",
         sortorder: "desc",
         usepager: true,
         singleSelect: true,
         title: 'Test',
         useRp: true,
         rp: 20,
         showTableToggleBtn: false,
         width: 500,
         height: 250
      });

     // You can setup all the tables you need here.

   });

 </script>
UberNeet
Hello and thank you for your feedback! I tried removing the 2 lines you mentioned and still didnt work. Then removed the history part of the tabs and still didnt work. Just playing around with it for some reason it seems the flexigrid cannot see/find the table id that is inside the second div: <table id="flex1" style="display:none"></table> Because the second I move that outside the tab code it loads just fine wherever I put the line of code above. So I was thinking maybe the jquery tab didnt allow access to id's inside the tab containers? Thats where Im stumped
John
Check the answer, I've updated it. I didn't find any trouble when using them both. I used jQuery 1.3.2.
UberNeet