sympatric greg
sympatric greg

Reputation: 3169

jqGrid (MVC): wanting to not load grid on page load

This post covers what I need to do: Use of local datatype to prevent grid load; however when I do this at $(document).ready(), the grid loads itself but the data then displays blank rows. (I notice that the number of rows returned is correct for the ajax call).

I've also tried specifying the model's BeforeAjaxRequest to set datatype:'local', but this doesn't happen in time to prevent the call either.

How can I stop the first grid load of a jqGrid declared in an MVC view?

Upvotes: 2

Views: 1533

Answers (2)

sympatric greg
sympatric greg

Reputation: 3169

Trirand has modified jqGrid so that if you wire up a BeforeAjaxRequest function and have that function return false, the request is not sent.

This resolves the problem nicely.

Upvotes: 3

Oleg
Oleg

Reputation: 221997

If I understand you correct you want that the empty grid will not displayed at the page load. You can do this in at leas two ways:

  • You can don't create the grid from the <table> and the optional pager <div> elements. So you can call $("#list").jqGrid({/*jqGrid parameters*/}); only if you want display the grid (at least as empty).
  • You can place <table> and the optional pager <div> elements in another container div which are hidden (<div id="mycontainer" style="display:none">...</div>) and make it visible ($("#mycontainer").show()) only if you want to show the grid.

Upvotes: 0

Related Questions