Render results on basis of window width

Render results on basis of window width

  

Hello Team,

I would like to know if there is a way I can load number of results on the basis of window size.


Example:

  • If window size is set to 1024, I should render  30 records
  • If window size is set to 1280,  I should render 20 records
  • If window size is set to 1920,  I should render 10 records


Looking forward for your valuable suggestions.


Thanks and Regards,
Atul Patel

Solution

Hi Atul.

Restrictions on the window side are usually done on the client side, with CSS - a technique called responsive web design.

You seem to want the browser window to affect the amount of data that the application returns. This means that your query will depend on the browser window, which is an unusual dependency. In this case, what would happen if the user resized the browser window after loading the page? What about user agents that have no window (such as robots or screen readers)?

I suggest you to recast your requirements using responsive web design. For example, you could always return 30 records, but depending on the window size you can hide 10 or 20 of those records (and you can use CSS / Javascript for that).

Solution