DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workkloads.

Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Designing for Security
  • Mastering GitHub Copilot: Top 25 Metrics Redefining Developer Productivity
  • The Best Programming Languages for Kids
  • Software Development Engagement Models: What To Choose

Trending

  • Rethinking Recruitment: A Journey Through Hiring Practices
  • Docker Model Runner: Streamlining AI Deployment for Developers
  • Create Your Own AI-Powered Virtual Tutor: An Easy Tutorial
  • AI Meets Vector Databases: Redefining Data Retrieval in the Age of Intelligence
  1. DZone
  2. Culture and Methodologies
  3. Agile
  4. How to resize an ExtJS Panel, Grid, Component on Window Resize without using Ext.Viewport

How to resize an ExtJS Panel, Grid, Component on Window Resize without using Ext.Viewport

By 
Loiane Groner user avatar
Loiane Groner
·
Aug. 24, 10 · News
Likes (0)
Comment
Save
Tweet
Share
48.2K Views

Join the DZone community and get the full member experience.

Join For Free

This post will walk through how to resize an ExtJS Panel, Grid, Component on Window Resize without using Ext.Viewport.



Problem:

You have a legacy page and you want to change an html grid for an ExtJS DataGrid, because it has so many cool features. Or you have a page with some design and you are going to use only one ExtJS Component. In both cases, you also want to render your ExtJS Component to a specific DIV. Also, you want you component to be resized in case you resize the browser window.

How can you do that if resize a single component in an HTML page it is not the default behavior of an ExtJS Component (except if you use Ext.Viewport)?

Solution:

Condor (from ExtJS Community Support Team) developed a plugin that can do that for you.

I had to spend some time to understand how the plugin works, and I finally got it working as I wanted.

Well, I recommend you to spend some time reading this thread: http://www.sencha.com/forum/showthread.php?28318 (if you have any issues or questions, please publish it on the thread, so other members can give you the support you need).

Requirements to make the plugin work:

Your have to apply the following style to the DIV (the width is up to you, the other styles are mandatory, otherwise it will not work):

<div id="reportTabContent" style="overflow: hidden; position:absolute; width:98%;"></div>

If you have any border around your ExtJS component, you have to set a HEIGHT. And you will also have to set a height to your ExtJS component. In this case, autoHeight will not work. If you DO NOT have any border or other design on the ExtJS component side, you do not need to set height and you can use autoHeight. In my case, I put a border on the external DIV, so I have to set Height:

<div style="border:3px solid #000000; padding:1px; width:99%; height:500px;">

HTML code (all DIVs):

<div style="border:3px solid #000000; padding:1px; width:99%; height:500px;">
	<table>
	<tr>
	<td style="overflow: hidden; width:100%;">
		<div id="reportTabContent" style="overflow: hidden; position:absolute; width:98%;"></div>
	</td>
	</tr>
	</table>
</div>

And you need to add the plugin to the component (In this case, I’m using an ExtJS DataGrid):

var grid = new Ext.grid.GridPanel({
store: store,
columns: [
{header: 'Company', width: 160, sortable: true, dataIndex: 'company'},
{header: 'Price', width: 75, sortable: true, renderer: 'usMoney', dataIndex: 'price'},
{header: 'Change', width: 75, sortable: true, renderer: change, dataIndex: 'change'},
{header: '% Change', width: 75, sortable: true, renderer: pctChange, dataIndex: 'pctChange'},
{header: 'Last Updated', width: 85, sortable: true, renderer: Ext.util.Format.dateRenderer('m/d/Y'), dataIndex: 'lastChange'}
],
stripeRows: true,
autoExpandColumn: 'company',
height: 490,
autoWidth:true,
title: 'Array Grid',
// config options for stateful behavior
stateful: true,
stateId: 'grid'
,viewConfig:{forceFit:true}
,renderTo: 'reportTabContent' // render the grid to the specified div in the page
,plugins: [new Ext.ux.FitToParent("reportTabContent")]
});

And done! Now you can resize the browser and the component will resize itself!

I tested it on Firefox, Chrome and IE6.

You can download my sample project from my GitHub: http://github.com/loiane/extjs-fit-to-parent

PS.: If you want to use the full browser window, use a Viewport.

Happy coding!

Design HTML Coding (social sciences) Requirement Internet Explorer 6 POST (HTTP) teams GitHub

Published at DZone with permission of Loiane Groner, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Designing for Security
  • Mastering GitHub Copilot: Top 25 Metrics Redefining Developer Productivity
  • The Best Programming Languages for Kids
  • Software Development Engagement Models: What To Choose

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!