日期:2014-05-16  浏览次数:20635 次

求extjs 可编辑grid
谁还有自己做过可编辑GRID的例子,能添加新行,能初始化数据,例如其中一列是选择框,数据是从数据库获取过来的

麻烦各位了。

------解决方案--------------------

    var sm = new Ext.grid.CheckboxSelectionModel(); // ext自带的CheckBox选择列
    var cm=new Ext.grid.ColumnModel([
     new Ext.grid.RowNumberer(),// 行号列
     sm,
     {
     header:"项目编号",
     dataIndex:"itemId",
     align:"center",
     width:80,
     sortable:true,
     editor:new Ext.grid.GridEditor(new Ext.form.TextField({allowBlank:false}))
     },
     {
     header:"项目值",
     dataIndex:"itemValue",
     width:180,
     sortable:true,
     editor:new Ext.grid.GridEditor(new Ext.form.TextField({allowBlank:false}))
     },
     {
     header:"排列顺序",
     dataIndex:"itemOrder",
     align:"center",
     width:80,
     sortable:true,
     editor:new Ext.grid.GridEditor(new Ext.form.TextField({allowBlank:false}))
     },
//     {
//     header:"是否有效",
//     dataIndex:"isLocked",
//     align:"center",
//     width:80,
//     sortable:true,
//     renderer:function(value){
//     return value ? "是" : "否";
//     }
////     ,
////     editor:new Ext.grid.GridEditor(new Ext.form.Checkbox({width:40,align:"center"}))
//     },
     {
     header:"项目说明",
     dataIndex:"itemRemark",
     width:240,
     sortable:true,
     editor:new Ext.grid.GridEditor(new Ext.form.TextField())
     },{
     dataIndex:"id",
     hidden:true
     },
     {
     dataIndex:"dictTypeId",
     hidden:true
     }
    ]);
    var gridpanel;
    //gridpanel头部工具栏
    var gridTbar = new Ext.Toolbar([{
        text : "新增",
        tooltip : "增加项目",
        icon : "../../pic/add-row.gif",
        handler : function() {
    &