سؤال

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?

هل كانت مفيدة؟

المحلول

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.

نصائح أخرى

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.
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top