代码如下:

Ext.onReady(function(){
       //定义列
var cm = new Ext.grid.ColumnModel([
{header: '编号', dataIndex: 'id'},
{header: '名称', dataIndex: 'name'},
{header: '描述', dataIndex: 'des'}
]); //数据定义
var data = [
['1001','name1','description1'],
['1002','name1','description1'],
['1003','name1','description1'],
['1004','name1','description1'],
['1005','name1','description1']
]; //数据源定义
var store = new Ext.data.Store({
proxy: new Ext.data.MemoryProxy(data),
reader: new Ext.data.ArrayReader({},[
{name: 'id'},
{name: 'name'},
{name: 'des'}
])
});
store.load(); //grid panel
var grid = new Ext.grid.GridPanel({
renderTo: Ext.getBody(),
store: store,
cm: cm
});
});

google了一下:In Extjs 4.0 ,there is no colModel config for GridPanel(http://www.sencha.com/forum/showthread.php?199720-Ext.grid.ColumnModel-is-not-a-constructor)然后查看其API:其用法如下

Ext.onReady(function(){
        Ext.create('Ext.data.Store', {
storeId: 'simpleStore',
fields: ['name', 'email', 'phone'],
data:{
'items':[
{'name':'yanshiying', 'email':'email', 'phone':'1234567890'},
{'name':'yanshiying', 'email':'email', 'phone':'1234567890'},
{'name':'yanshiying', 'email':'email', 'phone':'1234567890'}
]
},
proxy: {
type: 'memory',
reader: {
type: 'json',
root: 'items'
}
}
}); Ext.create('Ext.grid.Panel', {
title: 'Simple',
store: Ext.data.StoreManager.lookup('simpleStore'),
columns: [
{header: 'Name', dataIndex: 'name'},
{header: 'Email', dataIndex: 'email'},
{header: 'Phone', dataIndex: 'phone'}
],
height: 200,
width: 400,
renderTo: Ext.getBody()
});
})

运行效果:

Ext4.0.7使用Ext.grid.ColumnModel报错:TypeError: Ext.grid.Model is not a constructor的更多相关文章

  1. 安装php时,make步骤报错make: *** [ext/gd/gd.lo] Error 1

    安装PHP时,make步骤报错make: *** [ext/gd/gd.lo] Error 1 /usr/local/src/LAMP+memcahed+catci/php-5.4.0/ext/gd/ ...

  2. Selenium Grid 运行报错 Exception thrown in Navigator.Start first time ->Error forwarding the new session Empty pool of VM for setup Capabilities

    Selenium Grid 运行报错 : Exception thrown in Navigator.Start first time ->Error forwarding the new se ...

  3. org.apache.tomcat.util.descriptor.web.WebXml.setVersion Unknown version string [4.0]. Default version will be used.报错

    org.apache.tomcat.util.descriptor.web.WebXml.setVersion Unknown version string [4.0]. Default versio ...

  4. 将Xcode升级到10.0以上版本,Appium启动报错的问题

    前言 现在的Xcode最新版本都是在10.1,原先使用的版本是9.4.1!结果今天手贱将其升级... 然后,跑IOS自动化时,出现“Xcode version '0.1'. Support for X ...

  5. django2.0+连接mysql数据库迁移时候报错

    django2.0+连接mysql数据库迁移时候报错 情况一 错误信息 django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 ...

  6. django2.0变动数据库设置外键报错

    1.报错TypeError: __init__() missing 1 required positional argument: 'on_delete' django2.0以后创建数据库外键的时候必 ...

  7. python 报错TypeError: 'range' object does not support item assignment,解决方法

    贴问题 nums = range(5)#range is a built-in function that creates a list of integers print(nums)#prints ...

  8. 完美解决 scipy.misc.imread 报错 TypeError: Image data cannot be converted to float

    File "/home/harrison/anaconda3/lib/python3.7/site-packages/matplotlib/image.py", line 634, ...

  9. 关于Jupyter Notebook无法自动补全(Autocompletion),报错TypeError: __init__() got an unexpected keyword argument 'column' 的解决方案

    关于Jupyter Notebook无法自动补全(Autocompletion),报错TypeError: __init__() got an unexpected keyword argument ...

随机推荐

  1. documentElement vs body

    document.documentElement与document.body. 2011-03-12 10:15:46|  分类: javascript|字号 订阅     这是DOMDocument ...

  2. cf E. Valera and Queries

    http://codeforces.com/contest/369/problem/E 题意:输入n,m; n 代表有多少个线段,m代表有多少个询问点集.每一个询问输出这些点的集合所占的线段的个数. ...

  3. C++中new和delete的背后( call edx 调用虚表内的第二个函数(析构函数))

    关于 C++中new背后的行为, 以前已经写过一篇了 理解C++中new背后的行为, 但是里面也只是泛泛而谈,没有真凭实据, 下面我们从汇编的角度看C++编译器究竟在背后干了什么?   我们的代码很简 ...

  4. Activity生命周期,状态保存恢复(经典)

    一.整体框架 二.main.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android&qu ...

  5. V$LATCH_PARENT和V$LATCH_CHILDREN

    V$LATCH_PARENT contains statistics about parent latches. The columns of V$LATCH_PARENT are identical ...

  6. BZOJ2750: [HAOI2012]Road

    2750: [HAOI2012]Road Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 261  Solved: 113[Submit][Status ...

  7. Linux企业级项目实践之网络爬虫(1)——项目概述及准备工作

    我们在学习了Linux系统编程之后,需要一些实战项目来提高自己的水平,本系列我们通过编写一个爬虫程序,将我们学习的知识进行综合应用,同时在实现项目的过程中逐渐养成一些有用的思维方式,并具有初步的软件开 ...

  8. cf492C Vanya and Exams

    C. Vanya and Exams time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  9. poj 2049 Let it Bead(polya模板)

      Description Cannery Row percent of the target audience insists that the bracelets be unique. (Just ...

  10. yaml 1.6 操作

    /** * Copyright (c) 2008, http://www.snakeyaml.org * * Licensed under the Apache License, Version 2. ...