`

extjs cellediting

阅读更多
1.项目使用extjs cellediting,使用后grid中的数据就是无法被修改,调了一上午加下午半小时终于知道问题所在:store中的api一定要有update项,且update指到的文件不能是数据原有文件。
store:
Ext.define('×××.store.×××',{
    extend:'Ext.data.Store',
    model:'×××.model.×××',
    autoLoad: true,
    autoSync: true,
    storeId: '×××',
    proxy:{
    	type:'ajax',
    	url:'data/×××.json',
    	api:{
    		read:'data/×××.json',
    		update:'data/×××Update.json',

    	},
    	reader:{
    		type:'json',
    		root:'×××',
    		successProperty:'success',
    		messageProperty:'message'
    	}
}

grid:
this.editing = Ext.create('Ext.grid.plugin.CellEditing', {
    		ptype:'cellediting',
        	clicksToEdit: 1,
        	autoCancel:false,
        	listeners:{
        		validateedit:{        			fn:this.000000000,
        			scope:this
        		}
        	}
    	});
Ext.apply(this,{
plugins:[this.editing],
……
});

000000000: function(editor, e, options) {
    	console.debug(" cell edit listener ");
        console.log(editor);
        console.log(e);
        console.log("e.value:"+e.value);
        console.log("options:"+options);
    }


2.extjs中和 Date相关的小问题
如果想要只允许用户选择今天之后的日期,只需设置:
minValue: new Date(),

设置在grid中显示的日期格式:
renderer: Ext.util.Format.dateRenderer('Y-m-d'),

示例代码如下:
{
    header: 'Deadline',
    dataIndex: 'deadline',
    flex:1,
    minWidth:100,
    renderer: Ext.util.Format.dateRenderer('Y-m-d'),
    field: {
         xtype: 'datefield',
         allowBlank: false,
         format: 'Y-m-d', //选择日期时显示的日期格式
         renderer: this.formatDate,
         minValue: new Date(),
         value:this.formatDate(value)
    }
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics