简体   繁体   English

在extjs网格单元格编辑中使用beforecheckchange侦听器获取单元格div ID

[英]Get cell div id using beforecheckchange listener in extjs grid cell editing

I am using beforeCheckChange listener for checkColumn in extjs grid cell editing. 我在extjs网格单元格编辑中为checkColumn使用beforeCheckChange侦听器。

Once unchecked, I want remove the dirty flag for this cell. 取消选中后,我要删除此单元格的脏标志。 So I am trying to remove "x-grid-dirty-cell" Cls, using cell div id. 因此,我尝试使用单元格div ID删除"x-grid-dirty-cell" Cls。

Ext.select("ext-gen2654").removeCls('x-grid-dirty-cell');

Following is listener 以下是听众

listeners: {
    beforecheckchange: me.onCheckcolumnBeforeCheckChange
}

onCheckcolumnBeforeCheckChange: function(comp, rowIndex, checked, eOpts) {  
    Ext.select("ext-gen2654").removeCls('x-grid-dirty-cell');
}

How do I get the div id for this cell only? 如何仅获得该单元格的div ID?

Let me know if we have any alternative to remove dirty record after uncheck. 让我知道是否有其他方法可以取消取消选中后删除脏记录。

Edited- display checkbox for alternative records 已编辑-显示复选框以显示备用记录

Ext.getCmp('grid').gridColumns[0]=  {
    xtype: 'checkcolumn',                                               
                dataIndex: 'SELECT',
                width: 55,
                stopSelection: true,
                renderer: function(value, metaData, record, rowIndex, colIndex, store, view) {
                if(row%2==0){  // i need to display alternative checkbox
                    var cssPrefix = Ext.baseCSSPrefix,
                    cls = cssPrefix + 'grid-checkcolumn';


                        if (this.disabled || value == 'N') {
                            metaData.tdCls += ' ' + this.disabledCls;
                        }
                if (!value) {
                cls += ' ' + cssPrefix + 'grid-checkcolumn-checked';
                }

                    return '<img class="' + cls + '" src="' + Ext.BLANK_IMAGE_URL + '"/>';
                        }

            }

,

try listener code to remove dirty mark, but no luck

    onCheckcolumnBeforeCheckChange: function(comp, rowIndex, checked, eOpts) {  
        var store=Ext.getCmp('grid').getStore();
        var record= store.getAt(rowIndex);
        if(checked==true){  
        record.dirty= false;
        record.commit();    
        store.commitChanges();

        }

If you want to remove the dirty flags for the whole grid, use markDirty on the grid view : 如果要删除整个网格的脏标志, markDirty在网格视图上使用markDirty

viewConfig:{
    markDirty:false
}

If you want to remove the dirty flags for the whole column only, just set a tdCls on the column: 如果只想删除整个列的脏标志,只需在该列上设置一个tdCls:

tdCls:'doNotMarkDirty',

and add the following CSS (tested in Classic theme, may be different for other themes): 并添加以下CSS(经过Classic主题测试,其他主题可能有所不同):

.doNotMarkDirty.x-grid-dirty-cell {
    background-image:none;
}

If you want to remove the dirty flags for the whole column, AND have the model ignore any changes made to the column, try adding a custom isModified function to the model definition : 如果要删除整个列的脏标志,并且让模型忽略对该列所做的任何更改,请尝试向模型定义添加自定义isModified函数

isModified:function(dataIndex) {
      if(dataIndex=="myDataIndex") return false;
      me.callParent(arguments);
}

If you want to let a record know that it is no longer dirty, check out record.commit() . 如果您想让一条记录知道它不再脏了,请签出record.commit()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM