版本:extjs 2.3.0
需求:自定义可排序列选择。
例子:http://localhost/ext230/examples/dd/dnd_grid_to_grid.html
封装:暂无,给大家参考下。
效果如图1所示。
图1
c.html:
-
<html>
-
<head>
-
<metahttp-equiv="Content-Type"content="text/html;charset=UTF-8"/>
-
<title>test</title>
-
-
<linkrel="stylesheet"type="text/css"href="./js/extjs/resources/css/ext-all.css"/>
-
-
-
<scripttype="text/javascript"src="./js/extjs/ext-base.js"></script>
-
-
<scripttype="text/javascript"src="./js/extjs/ext-all.js"></script>
-
-
<scripttype="text/javascript"src="c.js"></script>
-
-
</head>
-
<body>
-
-
-
<h1>DragandDropfromGridtoGridExample</h1>
-
<p>ThisexampleshowshowtosetuptwowaydraganddropfromoneGridPaneltoanother.</p>
-
<p>Notethatthejsisnotminifiedsoitisreadable.See<ahref="dnd_grid_to_grid.js">dnd_grid_to_grid.js</a>.</p>
-
<divid="panel"></div>
-
-
-
</body>
-
</html>
c.js
-
-
-
-
-
-
-
-
-
Ext.onReady(function(){
-
Ext.QuickTips.init();
-
-
-
varmyData={
-
records:[
-
{name:"名称0",column1:"0",column2:"0"},
-
{name:"名称1",column1:"1",column2:"1"},
-
{name:"名称2",column1:"2",column2:"2"},
-
{name:"名称3",column1:"3",column2:"3"},
-
{name:"名称4",column1:"4",column2:"4"},
-
{name:"名称5",column1:"5",column2:"5"},
-
{name:"名称6",column1:"6",column2:"6"},
-
{name:"名称7",column1:"7",column2:"7"},
-
{name:"名称8",column1:"8",column2:"8"},
-
{name:"名称9",column1:"9",column2:"9"},
-
{name:"名称10",column1:"9",column2:"9"},
-
{name:"名称11",column1:"9",column2:"9"},
-
{name:"名称12",column1:"9",column2:"9"},
-
{name:"名称13",column1:"9",column2:"9"},
-
{name:"名称14",column1:"9",column2:"9"},
-
{name:"名称15",column1:"9",column2:"9"},
-
{name:"名称16",column1:"9",column2:"9"},
-
{name:"名称17",column1:"9",column2:"9"},
-
{name:"名称18",column1:"9",column2:"9"},
-
{name:"名称19",column1:"9",column2:"9"}
-
]
-
};
-
-
-
-
varfields=[
-
{name:'name',mapping:'name'},
-
{name:'column1',mapping:'column1'},
-
{name:'column2',mapping:'column2'}
-
];
-
-
-
varfirstGridStore=newExt.data.JsonStore({
-
fields:fields,
-
data:myData,
-
root:'records'
-
});
-
-
-
-
varcols=[
-
{id:'name',header:"列名称",
-
-
sortable:true,
-
dataIndex:'name'
-
}
-
-
-
];
-
-
-
varfirstGrid=newExt.grid.GridPanel({
-
ddGroup:'secondGridDDGroup',
-
store:firstGridStore,
-
columns:cols,
-
enableDragDrop:true,
-
stripeRows:true,
-
autoExpandColumn:'name',
-
-
height:272,
-
columnWidth:0.4,
-
-
title:'待选择列'
-
});
-
-
varsecondGridStore=newExt.data.JsonStore({
-
fields:fields,
-
root:'records'
-
});
-
-
-
varsecondGrid=newExt.grid.GridPanel({
-
ddGroup:'firstGridDDGroup',
-
store:secondGridStore,
-
columns:cols,
-
enableDragDrop:true,
-
stripeRows:true,
-
autoExpandColumn:'name',
-
height:272,
-
columnWidth:0.4,
-
title:'已选择列'
-
});
-
-
varlrPanel={
-
columnWidth:0.1,
-
height:300,
-
-
items:[
-
newExt.Button({
-
text:">",
-
style:'margin:70px0px0px15px',
-
handler:function(){
-
if(firstGrid.getSelectionModel().hasSelection())
-
{
-
-
vartotal=secondGridStore.getCount();
-
varrecords=firstGrid.getSelectionModel().getSelections();
-
for(vari=0;i<records.length;i++){
-
varrecord=records[i];
-
firstGridStore.remove(record);
-
secondGridStore.insert(total+i,record);
-
}
-
}
-
}
-
}),
-
newExt.Button({
-
text:">>",
-
style:'margin:15px0px0px15px',
-
handler:function(){
-
-
vartotal=secondGridStore.getCount();
-
vari=0;
-
while(firstGridStore.getCount()>0)
-
{
-
varrecord=firstGridStore.getAt(0);
-
firstGridStore.remove(record);
-
secondGridStore.insert(total+i,record);
-
i++;
-
}
-
}
-
}),
-
newExt.Button({
-
text:"<",
-
style:'margin:15px0px0px15px',
-
handler:function(){
-
if(secondGrid.getSelectionModel().hasSelection())
-
{
-
-
vartotal=firstGridStore.getCount();
-
varrecords=secondGrid.getSelectionModel().getSelections();
-
for(vari=0;i<records.length;i++){
-
varrecord=records[i];
-
secondGridStore.remove(record);
-
firstGridStore.insert(total+i,record);
-
}
-
}
-
}
-
}),
-
newExt.Button({
-
text:"<<",
-
style:'margin:15px0px0px15px',
-
handler:function(){
-
-
vartotal=firstGridStore.getCount();
-
vari=0;
-
while(secondGridStore.getCount()>0)
-
{
-
varrecord=secondGridStore.getAt(0);
-
secondGridStore.remove(record);
-
firstGridStore.insert(total+i,record);
-
i++;
-
}
-
}
-
})
-
]
-
};
-
-
varudPanel={
-
columnWidth:0.1,
-
height:300,
-
items:[
-
newExt.Button({
-
text:"向上",
-
style:'margin:90px0px0px10px',
-
handler:function(){
-
if(secondGrid.getSelectionModel().hasSelection())
-
{
-
varrecord=secondGrid.getSelectionModel().getSelected();
-
-
vartotal=secondGridStore.getCount();
-
for(vari=0;i<total-1;i++){
-
vartemp=secondGridStore.getAt(i);
-
if(temp.get('name')==record.get('name'))
-
{
-
break;
-
}
-
varnext=secondGridStore.getAt(i+1);
-
if(next.get('name')==record.get('name'))
-
{
-
secondGridStore.remove(next);
-
secondGridStore.insert(i,next);
-
}
-
}
-
}
-
}
-
}),
-
newExt.Button({
-
text:"向下",
-
style:'margin:15px0px0px10px',
-
handler:function(){
-
if(secondGrid.getSelectionModel().hasSelection())
-
{
-
varrecord=secondGrid.getSelectionModel().getSelected();
-
-
vartotal=secondGridStore.getCount();
-
for(vari=0;i<total-1;i++){
-
varnext=secondGridStore.getAt(i);
-
if(next.get('name')==record.get('name'))
-
{
-
secondGridStore.remove(next);
-
secondGridStore.insert(i+1,next);
-
}
-
}
-
}
-
}
-
})
-
]
-
};
-
-
-
-
vardisplayPanel=newExt.Panel({
-
width:650,
-
height:300,
-
-
layout:'column',
-
renderTo:'panel',
-
items:[
-
firstGrid,
-
lrPanel,
-
secondGrid,
-
udPanel
-
],
-
bbar:[
-
'->',
-
{
-
text:'确定',
-
handler:function(){
-
-
vartotal=secondGridStore.getCount();
-
varresults="";
-
if(total>0)
-
{
-
for(vari=0;i<total;i++)
-
{
-
varrecord=secondGridStore.getAt(i);
-
results+=record.get("name")+",";
-
}
-
results=results.substring(0,results.length-1);
-
}
-
alert("选择的列名称:"+results);
-
}
-
},
-
{
-
text:'重置',
-
handler:function(){
-
-
firstGridStore.loadData(myData);
-
-
-
secondGridStore.removeAll();
-
}
-
}
-
]
-
});
-
-
-
varblankRecord=Ext.data.Record.create(fields);
-
-
-
-
-
-
varfirstGridDropTargetEl=firstGrid.getView().el.dom.childNodes[0].childNodes[1];
-
varfirstGridDropTarget=newExt.dd.DropTarget(firstGridDropTargetEl,{
-
ddGroup:'firstGridDDGroup',
-
copy:true,
-
notifyDrop:function(ddSource,e,data){
-
-
-
functionaddRow(record,index,allItems){
-
-
-
varfoundItem=firstGridStore.find('name',record.data.name);
-
-
if(foundItem==-1){
-
firstGridStore.add(record);
-
-
-
-
-
-
ddSource.grid.store.remove(record);
-
}
-
}
-
-
-
Ext.each(ddSource.dragData.selections,addRow);
-
return(true);
-
}
-
});
-
-
-
-
varsecondGridDropTargetEl=secondGrid.getView().el.dom.childNodes[0].childNodes[1]
-
-
vardestGridDropTarget=newExt.dd.DropTarget(secondGridDropTargetEl,{
-
ddGroup:'secondGridDDGroup',
-
copy:false,
-
notifyDrop:function(ddSource,e,data){
-
-
-
functionaddRow(record,index,allItems){
-
-
-
varfoundItem=secondGridStore.find('name',record.data.name);
-
-
if(foundItem==-1){
-
secondGridStore.add(record);
-
-
-
-
-
ddSource.grid.store.remove(record);
-
}
-
}
-
-
Ext.each(ddSource.dragData.selections,addRow);
-
return(true);
-
}
-
});
-
});
分享到:
相关推荐
For example, you can specify the color, style, and font for every element of the grid, define the type and style of lines. Enforcing application look and feel standards is much easier using the ...
BCGPGridExample: added new visual managers and new 2 tabs: "Drag and Drop" and "Easy Input" BCGPIE7Demo: the tab control was fully redesigned and derived from the library MDI Tab control. ...
Double-click on an item to paste the text in the cursor location of the current editor or drag & drop it to a specific location in an editor. You can use the editor preferences to configure when and...
Double-click on an item to paste the text in the cursor location of the current editor or drag & drop it to a specific location in an editor. You can use the editor preferences to configure when and...
Double-click on an item to paste the text in the cursor location of the current editor or drag & drop it to a specific location in an editor. You can use the editor preferences to configure when and ...
Double-click on an item to paste the text in the cursor location of the current editor or drag & drop it to a specific location in an editor. You can use the editor preferences to configure when and...
Double-click on an item to paste the text in the cursor location of the current editor or drag & drop it to a specific location in an editor. You can use the editor preferences to configure when and ...
Double-click on an item to paste the text in the cursor location of the current editor or drag & drop it to a specific location in an editor. You can use the editor preferences to configure when and...
An Android ViewGroup that implements a paged grid with drag'n'drop movable items Supports Android 2.2 (API 8) and up Tested on a Nexus One, Galaxy Nexus and a Nexus 7 Example video: v0.1 : ...
convertbase.zip VB has built in functions for converting from decimal to Hex and Octal, but nothing for converting from Octal and Hex to decimal (correct us if we are wrong), or from binary to ...
Q495393 - Card View - Moving a row within a card using drag and drop scrolls the card content up to the first visible row and hides this row under the card bottom edge in certain cases Q487880 - ...
Q495393 - Card View - Moving a row within a card using drag and drop scrolls the card content up to the first visible row and hides this row under the card bottom edge in certain cases Q487880 - ...
filedroplistctrl.zip This article explains how to support file drag and drop in your CWnd-derived object(40KB)<END><br>83,DrivePickerList.zip A control that shows drive names and icons like ...
- Drag & Drop拖拽操作 - Tooltip提示框设置 - Popup弹窗对话框 7. **样式定制**: - Theme主题切换 - CSS3样式应用 - SASS预处理器集成 8. **性能优化**: - Lazy Loading懒加载技术 - Virtual Scrolling...
We recommend to use TMS components to create modern user interfaces, toolbars and ribbons. 19.2.2013 - WPTools 6.29.1 - fix in rtf writing code to solve problem with merged cells - fix possible range...
(71KB)<END><br>86,step0.zip A series of articles that resulted from experimenting with adding Drag and Drop features to my existing application. (16KB)<END><br>87,undo.zip Easily add Undo/Redo ...
- **Drag and Drop (拖放)**: 支持常见的拖放功能。 - **Utilities (工具)**: 包括一系列辅助函数和工具类,如日期处理、动画效果等。 ##### 如何引用 为了在项目中使用 ExtJS,需要在 HTML 文件中通过 `<script>`...
actions.dragAndDrop(source, target).perform(); ``` - **导航(Navigation and History)**: 导航至新的URL或返回上一页: ```java driver.navigate().to("http://www.example.com"); driver.navigate().back()...
actions.drag_and_drop(source, target).perform() ``` **3.4 在窗口与框架之间移动** 当页面包含多个窗口或框架时,可能需要在它们之间切换。Selenium 提供了相应的 API 来处理这种情况: ```python # 切换到...