Only displaying X number of results even if more are returned

Only displaying X number of results even if more are returned

robamacafrobamacaf Posts: 9Questions: 0Answers: 0
edited January 2012 in General
This might sound like an odd request but is there anyway to have it show only, let's say 10 results, even if more are returned? I don't want 10 per page, I just want 10 total. (or whatever number I decide). I am currently returning a bigger results set because of the way I have to get the info from the database. But I only want to display the top 10 answers and the rest wouldn't show. If i use pagination I can get it to show 10 on every page (I don't want this). If I turn pagination off then it shows all 100 (I don't want this either). I just want to see the top 10

Any help would be great!

Replies

  • robamacafrobamacaf Posts: 9Questions: 0Answers: 0
    No one has any idea how to do this?
  • allanallan Posts: 63,540Questions: 1Answers: 10,476 Site admin
    There are two ways that I think of off the top of my head:

    1. Use pagination, but remove the pagination control :-). Bit of a cheat, but its probably the easiest way - just remove the 'p' option from sDom .

    2. Use fnServerData and 'post-process' your returns array. Chop it down to the size you want and then give it to DataTables for rendering.

    Allan
  • robamacafrobamacaf Posts: 9Questions: 0Answers: 0
    Wow! I can't believe it was that easy. I was forgetting to take off the 'p'. The second option isn't an option because of how I'm doing the processing and formatting the return response. But the first one worked perfect
This discussion has been closed.