Buffer Grid Example : GridPanel « Ext JS « JavaScript DHTML

Buffer Grid Example


 * Ext JS Library 3.0.0
 * Copyright(c) 2006-2009 Ext JS, LLC
 * licensing@extjs.com
 * http://www.extjs.com/license
<title>Hello World Window</title>
<link rel="stylesheet" type="text/css" href="ext-3.0.0/resources/css/ext-all.css" />
<script type="text/javascript" src="ext-3.0.0/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="ext-3.0.0/ext-all.js"></script>
<script type="text/javascript" src="ext-3.0.0/examples/ux/BufferView.js"></script>
  <style type="text/css">
  .x-grid3-td-topic b {
      font-family:tahoma, verdana;
  .x-grid3-td-topic b i {
      font-style: normal;
  .x-grid3-td-topic .x-grid3-cell-inner {
      white-space: nowrap;

<!-- Revised from demo code in ext3.0.0 -->
<script type="text/javascript">
 * Ext JS Library 3.0.0
 * Copyright(c) 2006-2009 Ext JS, LLC
 * licensing@extjs.com
 * http://www.extjs.com/license

    var store = new Ext.data.Store({
        remoteSort: true,
        baseParams: {lightWeight:true,ext: 'js'},
        sortInfo: {field:'lastpost', direction:'DESC'},
        autoLoad: {params:{start:0, limit:500}},

        proxy: new Ext.data.ScriptTagProxy({
            url: 'http://extjs.com/forum/topics-browse-remote.php'

        reader: new Ext.data.JsonReader({
            root: 'topics',
            totalProperty: 'totalCount',
            idProperty: 'threadid',
            fields: [
                'title', 'forumtitle', 'forumid', 'author',
                {name: 'replycount', type: 'int'},
                {name: 'lastpost', mapping: 'lastpost', type: 'date', dateFormat: 'timestamp'},
                'lastposter', 'excerpt'

    var grid = new Ext.grid.GridPanel({
        renderTo: 'topic-grid',
        title:'ExtJS.com - Browse Forums',
    autoExpandColumn: 'topic',
        store: store,

        columns: [new Ext.grid.RowNumberer({width: 30}),{
            id: 'topic',
            header: "Topic",
            dataIndex: 'title',
            width: 420,
            renderer: renderTopic,
            header: "Replies",
            dataIndex: 'replycount',
            width: 70,
            align: 'right',
            id: 'last',
            header: "Last Post",
            dataIndex: 'lastpost',
            width: 150,
            renderer: renderLast,

      bbar: new Ext.PagingToolbar({
        store: store,

      view: new Ext.ux.grid.BufferView({
        // custom row height
        rowHeight: 34,
        // render rows as they come into viewable area.
        scrollDelay: false

    // render functions
    function renderTopic(value, p, record){
        return String.format(
                '<b><a href="http://extjs.com/forum/showthread.php?t={2}" target="_blank">{0}</a></b><a href="http://extjs.com/forum/forumdisplay.php?f={3}" target="_blank">{1} Forum</a>',
                value, record.data.forumtitle, record.id, record.data.forumid);
    function renderLast(value, p, r){
        return String.format('{0}<br/>by {1}', value.dateFormat('M j, Y, g:i a'), r.data['lastposter']);



<div id="topic-grid"></div>


Related examples in the same category

1.Sort table by name
2.Add row to a table
3.Remove a row from a table
4.Remove all data from GridPanel
5.Layout GridPanel(table) and FormPanel in border layout
6.Using a Grid with a Form
7.Table Selection
8.The Grid demonstrates the use of creation of derived fields in a Record created using a custom convert function, and the use of column renderers.
9.Set column name, width, height, title for Ext.grid.GridPanel
10.Set column to sortable
11.Add rowselect event handler to a GridPanel
12.GridPanel: framing
13.GridPanel: buttons
14.GridPanel: toolbars
15.Add buttons to GridPanel
16.Static data grid
17.Reload data to GridPanel
18.Grid Plugins
19.stripeRows: true,
20.Grouping GridPanel
21.GridPanel Framed with Checkbox Selection and Horizontal Scrolling
22.Grid with Numbered Rows and Force Fit
23.Set autoExpandColumn for GridPanel
24.autoExpandColumn: 'column name',
25.Set up data, column for Ext.grid.GridPanel
26.Set RowSelectionModel for Ext.grid.GridPanel
27.Data Binding Example - Implemented with classes
28.Mark changed field
29.Updating the grid data via a button click
30.Define RowSelectionModel and set single selection
31.Define column model and set header, dataIndex and sortable
32.Create a grid with from an existing, unformatted HTML table.