views:

35

answers:

1

Hi,

Hi I am currently using JQGrid inside a JQuery UI Tab. My problem is that when I call the render JQGrid it disables(Grayed out with diagonal stripes).

<script type="text/javascript">
    $(document).ready(function () {
        $("#divTimePeriod").tabs();

        jQuery("#listTimePeriod").jqGrid({
            url: '/TimePeriod/GetTimePeriods',
            datatype: 'json',
            mtype: 'GET',
            colNames: ['', 'TimePeriodKey'],
            colModel: [
          { name: 'Actions', index: 'Actions', width: 60, sortable: false },
          { name: 'TimePeriodKey', index: 'TimePeriodKey', width: 55 },
        ],
            jsonReader: {
                repeatitems: false,
                root: "result"
            },
            pager: '#pagerTimePeriod',
            viewrecords: true,
            gridComplete: function () {

            }

        });
    });
</script>

<h3>Time Period Service</h3>
<div id="divTimePeriod">
    <ul>
        <li><a href="#TimePeriod">Time Period</a></li>
        <li><a href="#DayType">Day Type</a></li>
        <li><a href="#Interval">Interval Group</a></li>
        <li><a href="#Calendar">Calendar</a></li>
    </ul>

    <div id="TimePeriod">
       <span>Name: </span> <select><option></option><option>Default</option><option>All</option><option>Summer Off/On Peak</option></select>
        <table id="listTimePeriod" width="100%"></table> 
        <div id="pagerTimePeriod"></div>
    </div>
    <div id="DayType">
        <% Html.RenderPartial("~/Views/DayType/Contents.ascx"); %>
    </div>
    <div id="Interval">
        <% Html.RenderPartial("~/Views/IntervalGroup/Contents.ascx"); %>
    </div>
    <div id="Calendar">
        Calendar
    </div>
</div>  

The grid renders correctly but the tab remains grayed out.

Thanks

+1  A: 

You need to wait until the tab is initialized before creating your jqGrid.

For example, you can place your initialization code in the tab's show event, so that it is not executed until the tab is ready:

$("#divTimePeriod").tabs({
   show: function(event, ui) { 
     if (ui.index == 0){ // First tab is shown...
        // Initialize your jqGrid here
     }
   }
});
Justin Ethier
Thanks for the reply Justin, but it still displays similar problem.
Roy Astro
You could try temporarily commenting-out the content from the other tabs to see if one of them is causing the problem. Beyond that, I think you are going to have to post more of your code in order for us to begin to narrow-down the problem.
Justin Ethier
Thanks Justin. I will first try your suggestion and post an update.
Roy Astro
Hi Justin. Just found out that the problem was just i missed to include the <link href="../../Content/ui.jqgrid.css" rel="stylesheet" type="text/css" />. Oh my. Thanks again.
Roy Astro
No problem, glad you tracked it down :)
Justin Ethier