ASP.NET: Responsive GapFree MultiColumn Grids using Nested.js
DEMO DOWNLOAD MultiColumn Dynamic Grid Layouts are very popular nowadays and Pinterest , the fastest growing social network i...
https://www.programming-free.com/2013/02/aspnet-responsive-jquery-dynamic-grid.html?m=0
MultiColumn Dynamic Grid Layouts are very popular nowadays and Pinterest, the fastest growing social network is a familiar real time example of the same. There are many jQuery plugins available for creating such layouts starting from the jQuery Masonry plugin.
Recently, I discovered the existence of a new dynamic grid plugin called Nested developed by Jonas Blomdin that can be used to create a gap free, responsive dynamic grid layout. He had explained clearly how this plugin is different from the established masonry plugin here and that is the reason why I chose the Nested jQuery plugin along with FancyBox jQuery Plugin to create an image portfolio that consists of responsive multicolumn image grids. In this post, I am going to explain how to create responsive multicolumn dynamic grids in ASP.NET using Nested.js plugin.
Recently, I discovered the existence of a new dynamic grid plugin called Nested developed by Jonas Blomdin that can be used to create a gap free, responsive dynamic grid layout. He had explained clearly how this plugin is different from the established masonry plugin here and that is the reason why I chose the Nested jQuery plugin along with FancyBox jQuery Plugin to create an image portfolio that consists of responsive multicolumn image grids. In this post, I am going to explain how to create responsive multicolumn dynamic grids in ASP.NET using Nested.js plugin.
There are three things that this plugin do,
- Creates a matrix of all elements and creates a multi column grid.
- Scans the matrix for gaps and tries to fill them by re-ordering the elements.
- Resize any element at the bottom of the grid that is bigger (or smaller) than the gap to make the grid completely gap-free.
Steps to follow to implement this,
1. Download Nested jQuery plugin from here.
2. Add the jQuery.nested.js and style.css file from the download to your asp.net project.
3. We are going to display images of varying size using Repeater control. In this scenario, there are two parameters that is required for each grid, one is the value for image source, and the other is the cssclass for each grid.
To understand this let us see how it works in simple html. Each grid item should use css class as explained below,
To understand this let us see how it works in simple html. Each grid item should use css class as explained below,
<div id="container">
<div class="box size11"></div>
<div class="box size12"></div>
<div class="box size21"></div>
<div class="box size22"></div>
...
</div>
Sizing of items are handled by adding sizeWH where W is the number of columns the box shall use and H is the number of rows the box shall use. For example, size12 equals to 1 column and 2 rows, to display an image in this grid, the image should be of 50 X 100 in size.
The base column and row size is set by minWidth option and default is 50. This option can be changed anytime using,
$("#container").nested({minWidth: 100});To implement the same in asp.net, copy and paste the below code in .aspx file. Make sure you have included the necessary script and css files mentioned in point 1. I have used 27 images in various sizes as explained above to create this portfolio, for example size11 - 50 X 50, size 21- 100 X 50. etc. You can use images or any other content, such as text, buttons and other controls as content for the grid.
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Responsive MultiColumn Grid Example</title> <link href="style.css" rel="stylesheet" type="text/css" /> <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> <script src="jquery.nested.js" type="text/javascript"></script> <script type="text/javascript" > $(function() { $('#container').nested(); </script> </head> <body> <form id="form1" runat="server"> <div id="container"> <asp:Repeater ID="Repeater1" runat="server"> <ItemTemplate> <div class="<%#Eval("CssClassVal")%>"> <img src="<%# Eval("SmallUrl")%>" alt="" /> </div> </ItemTemplate> </asp:Repeater> </div> </form> </body> </html>
4. Use the below code in the code-behind page, here I am building a list that consists of information required for rendering the image such as the size of the image to be supplied to css class, (eg. 11,21.etc) and the path of image to be used by the src attribute. I have stored all images in Images/images_small folder and followed the same naming convention for all the images as in 'img_x.jpg', x starting from 1 to 27.
public class ImageAttributes { public string SmallUrl { get; set; } public string CssClassVal { get; set; } } public static class PopulateRepeater { static List<ImageAttributes> objList; public static IEnumerable<ImageAttributes> GetData() { ImageAttributes obj; objList = new List<ImageAttributes>(); //Image size for each image used in the project eg. size53 - 250x150 px int[] csssize = new int[]{53,42,34,11,22,45,43,24,37,32,53,23,12,21,23,22,11, 64,11,12,23,22,11,21,12,11,11}; for (int i = 1; i <=27; i++) { obj = new ImageAttributes(); obj.SmallUrl = String.Format("Images/images_small/img_{0}.jpg",i); int size=csssize[i-1]; obj.CssClassVal = String.Format("box size{0}",size); objList.Add(obj); } return objList; }
5. Bind Repeater control with values from PopulateRepeater Class in Page load method as shown below,
protected void Page_Load(object sender, EventArgs e) { Repeater1.DataSource = PopulateRepeater.GetData(); Repeater1.DataBind(); }
6. That is all, now build the project and open .aspx file in the browser to see the results. Resize browser window to know how the image grids re-align automatically according to the window size.
Caution:
There is a bug in this plug-in that causes the browsers to freeze due to an infinite loop when the viewport is reduced to less than the size of the widest element in the grid. There is a local fix available here. So whenever you use the jquery.nested.js file, make sure you edit the _renderGrid() method in it as mentioned in the issues page.
Please leave your comments and queries about this post in the comment sections in order for me to improve my writing skills and to showcase more useful posts. Thanks for reading!!
best
ReplyDeleteThank you so much for help, Dakota Johnson Classic Jacket
ReplyDeleteWe are so delighted to be your go-to animation studio! Whether you need a logo animation, animated video, or TV commercial, we’ve got just the artistic touch. Experts at our animation video production are happy to take your needs and elevate them with their unique style. We can work on a variety of different video content types including social media animations, corporate animations, business animations, cartoon animations, brand animations and what not.
ReplyDeleteHi, I am John Smith I am Web Developer, It is an amazing blog thanks for the sharing the blog. Frantic infotech provide the php web development company such as an information about software development for costumer service. Frantic infotech also provide the Hardware Mobile App Development. The development of advanced web applications is Orient Software’s specialty and we will successfully fulfill all your web application development requirements, from small-sized to wider-ranged projects.
ReplyDeleteMake your Magento application management easy with the best magento dedicated hosting. Devrims offers a next-gen managed cloud hosting platform that allows store owners & digital agencies to efficiently run their eCommerce store with high performance, fully managed and no server downtime.
ReplyDeleteGreen card holders who transport between home nation and USA or individuals who just got green card status (Any Age) will be qualified for new settlers protection plans. The green card holders who for all time gets comfortable USA will be qualified to buy Significant clinical protection plans like Blue Cross Blue Safeguard, Aetna, Song of devotion, Cigna, UnitedHealthCare and some more.. in light of the age. If it's not too much trouble, call us for more nitty gritty data. Get new immigrant insurance at affordable price so do contact us.
ReplyDeleteTo know more about this visit: https://www.visitorsinsurance.com/Green-card-Immigrant-Plans.asp
Contact US:
Location: 425 Huehl Road,Suite 22-A,Northbrook,IL 60062
Phone : 1-847-897-5120 | Fax : 1.847.897.5130 | Toll Free : 1-800-344-9540
WhatsApp : 1-847-897-5120 | Email: info@visitorsinsurance.com
Website: http://www.visitorsinsurance.com
http://www.facebook.com/myvisitorsinsurance
https://www.trustpilot.com/review/www.visitorsinsurance.com
http://www.linkedin.com/company/visitorsinsurance
Asp.Net is a server side sripting language and thier abbreviation is active server pages,new and enhance technolgy.When I was using the responsive gap free multi columns grid using node js.This is mainly used to backend development and Iam writing research paper help service that is submitted by university on the given deadline.
ReplyDeleteAfter seeing this post only i am realizing Pinterest using jQuery for their Masonry plugin for layout appearance. Hereafter whenever i see grid layouts in Pinterest, definitely this post will come to my mind. Thanks for sharing such a knowledgeable post for us. Keep sharing these kind of post which is useful for us.
ReplyDeleteDUI Lawyers In Arlington
I'm glad to hear that the post was informative for you and that it helped you to recognize the use of jQuery for Pinterest's Masonry plugin. It's interesting to learn about the technologies used in creating various websites and applications, and I hope this knowledge comes in handy for you in the future. Thank you for your feedback and for reading the post! Bankruptcy near me attorney
ReplyDeleteExplore WebPays that proactively protect your business and customers against fraud and data breaches without impacting real transactions. Get ready to leverage a unified and all-in-one credit card payment solution to accept credit card payments in a secure environment.
ReplyDeleteElevate your business with our cutting-edge white label payment gateway solutions, tailored to meet your unique needs and customer expectations. Are you planning to start your own payment gateway business today ? Reach us out and get to know everything in details.
ReplyDeleteCube Peaks excels in delivering top-notch Microsoft Dynamics services that empower businesses to enhance their operations and drive growth. With their expertise in implementing and customizing Microsoft Dynamics solutions, Cube Peaks helps organizations streamline their processes, improve customer relationships, and make data-driven decisions. Their comprehensive support ensures clients maximize the potential of their Dynamics systems, leading to increased efficiency and productivity. If you're looking for a partner to elevate your business with Microsoft Dynamics, Cube Peaks is the go-to choice!
ReplyDeleteNiftyspot is like the color pencil that brings vibrant ideas to life in the tech world! With a creative approach and an eye for detail, they add a unique touch to every project, making digital solutions as sharp and dynamic as a well-drawn masterpiece. Their team knows how to blend innovation with precision, creating impactful results for clients every time.
ReplyDeleteThe goal is to monitor coral attraction and growth using Intelli Reefs biomimicking .Let me begin by setting your expectations. There will be no readymade classes that you can just add to your tags and call it done. substrates throughout best landau medical scrubs USA this summer's coral spawning period.
ReplyDelete