asp.net mvc - mvc jquery paging search results with only 1 query -


I have the search page that I'm implementing as part of the asp.net + MVC + jquery site. The search query gets every result that comes back as part of the result set. I.e. high score for near match

Because the result set can change, and because the scores of matches are somewhat deep, I only want to load the results once and want to find a way to click through one of the results Pages

I thought I would create a page that will have all the search results (each result has its own) and just show / hide a subset by clicking the button associated with the jquery code. I think seems to be how can I see this before trying to do this work (I'm still quite new to jquery), but first I thought that anyone thought better is. / P>

Thanks in advance for any suggestions.

Edit: Francisco's suggestion was only necessary to me that I implemented it with some minor changes and with the 'j' N-M output N 'label the first / last / Create some jquio buttons to navigate to the next / final page. Thanks for all the suggestions.

I think your idea is quite good.

Just put all the elements in different differens divs from each page. Then div can be easily identified by a class or id attribute, such as:

   

etc.

The jQuery code will look like this:

  $ ("# page1"). Show (); Hide $ (".divpage"). // This hides all other divs  

Edit:

To do this dynamically, the persistence associated with your list Create a typed sequence result from. The title of the scene should be something like:

  & lt;% @ page title = "" language = "c #" masterpagefile = "~ / view / share / site.master" inheritance = " System.Web.Mvc.ViewPage & LT; IEnumerable & LT; Results & gt; & gt; "& Gt%;    

Then in your consideration, you put it:

     

Int current result = 0; Int numPage = 0; Leading (different items in the model) {If (current result == 0) Response. Type ("& lt; div id =" page "+ numPage +" \ "class = \" divpage \ "& gt;"); & Gt%; & Lt;% = item.score.ToString ()% & gt; & Lt;% = item.data% & gt; & Lt;% currentResults ++; If (currentResults> results page) {numPage ++; CurrentResults = 0; Response.Write ("& lt; / div>"); }}% ​​& Gt; & Lt;% If (Current Result! = 0) Response Type ("& lt; / div & gt;");% & gt;

then for your button:

  for <% (int i = 0; i & lt; numpage; i ++) { % & Gt; & Lt; A href = "" onclick = "show page ('<% = i% & gt;'); Return Back;" & Gt; Page & lt;% = i% & gt; & Lt; / A & gt; & Lt;%}% & gt; & Lt; Script type = "text / javascript" & gt; Function show page (number) {$ ("# page" + number). Show (); Hide $ (".divpage"). } & Lt; / Script & gt;  

Finally, in your controller:

  public action result ShowResults () {list & lt; Results & gt; Results = getResultsOrdererdByScoreFunction (); See Return (Results); }  

Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -