日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 前端技术 > javascript >内容正文

javascript

1.EXTJS Row Editor Grid 点取消时插入的新行 的解决方法

發(fā)布時(shí)間:2024/4/17 javascript 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 1.EXTJS Row Editor Grid 点取消时插入的新行 的解决方法 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

1.EXTJS??Row?Editor?Grid??點(diǎn)取消時(shí)插入的新行?的解決方法?<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

????<link?rel="stylesheet"?type="text/css"?href="/public/css/RowEditor.css"?/>

<script?type="text/javascript"?src="/public/js/Plugins/RowEditor.js"></script>

將新增?刪除放到行后面。??

{header:?'操作',

dataIndex:?'opt',

name:'opt',

align:?'center',

width:?100,

renderer:function(val,?metadata,?record,?rowIndex,?colIndex,?store){?

var?grid_id=this.name;?

return??"<input?type='button'?style='background-Color:#FFF;border:0;font-size:?12px;'? value='新增'?οnclick='add_row("+rowIndex+",\""+grid_id+"\");'/>?"?+"<input?type='button'? style='background-Color:#FFF;border:0;font-size:?12px;'?value='刪除'? οnclick='del_row(\""+grid_id+"\");'/>";

?}

外部函數(shù)

function?add_row(Index,grid_id)?{

????var?grid?=?Ext.getCmp(grid_id);

????grid.addRow(Index);

}

function?del_row(grid_id)?{

????var?grid?=?Ext.getCmp(grid_id);

????grid.isEdit?=?false;

????grid.delRow(true);

}

初始化時(shí)的函數(shù)?控制內(nèi)的函數(shù)。

addRow?:?function(Index){

????????var?Employee?=?Ext.data.Record.create([{

????????????????name:?'id'

????????????}]);

var?u?=?new?Employee({

id:?""??

});

this.editor.stopEditing();

this.store.insert(Index+1,u);??//在當(dāng)前行的下一行插入

this.getView().refresh();

this.getSelectionModel().selectRow(Index+1);

this.editor.startEditing(Index+1);

},

delRow:function(){

this.editor.stopEditing();

????????if(!this.isEdit)?{

????????????if(this.store.getCount()?!=?1)

????????????{

????????????????var?rec?=?this.getSelectionModel().getSelected();

????????????????this.store.remove(rec);

????????????????this.getView().refresh();

????????????}else{

????????????????alert('至少要有一個(gè)屬性。')

????????????}

????????}

}

New一個(gè)編輯的面板

?var?editor?=?new?Ext.ux.grid.RowEditor({

clicksToEdit?:?2,??//去掉單擊編輯情況

saveText:?'確定'?,

????????????cancelText:?'取消',

????????????onRowDblClick:?function(g,?rowIndex,?e){

????????????????this.startEditing(rowIndex,?false);

????????????????this.doFocus.defer(this.focusDelay,?this,?[e.getPoint()]);

????????????????_this.isEdit?=?true;??//雙擊的時(shí)候設(shè)置為true?利用這個(gè)來控制取消的時(shí)候不刪除。

????????????},

????????????listeners?:?{

????????????????canceledit?:?function(re,isPress){

????????????????????if(isPress){

????????????????????????_this.delRow();??點(diǎn)擊取消時(shí)調(diào)用刪除方法。防止插入的行留空問題

????????????????????}

????????????????}?

????????????}

});

轉(zhuǎn)載于:https://www.cnblogs.com/holyes/archive/2012/06/01/97fa7b99d59c9931fea2bcc1c02467a7.html

總結(jié)

以上是生活随笔為你收集整理的1.EXTJS Row Editor Grid 点取消时插入的新行 的解决方法的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。