Dec 09, 2011, 1:12 PM
two grids rows
Hi all,
I am using two grid example in a user control https://examples1.ext.net/#/GridPane...ous/Two_Grids/
but when i want to transfer rows from Gridpanel1 to Gridpanel 2 javasript error :
my code is :
thanks,
I am using two grid example in a user control https://examples1.ext.net/#/GridPane...ous/Two_Grids/
but when i want to transfer rows from Gridpanel1 to Gridpanel 2 javasript error :
source.store.getSelections is not a function
var records = source.store.getSelections();
my code is :
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
//using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Ext.Net;
using System.Data.SqlClient;
using System.Text;
namespace Project
{
public partial class Ejemplo : System.Web.UI.Page
{
Store Store1 = new Store();
JsonReader jsonr1 = new JsonReader();
RecordField desc_show = new RecordField();
PageProxy ProxyDatos = new PageProxy();
Store Store2 = new Store();
JsonReader jsonr2 = new JsonReader();
RecordField desc_show2 = new RecordField();
PageProxy ProxyDatos2 = new PageProxy();
protected void Page_Load(object sender, EventArgs e)
{
Window window1 = new Window();
window1.ID = "Window1";
window1.Closable = false;
window1.Height = 553;
window1.Width = 700;
window1.Icon = Icon.WorldAdd;
window1.Title = "Selector 1";
window1.Padding = 5;
window1.BodyBorder = false;
Store1.ID = "Store1";
Store1.AutoLoad = true;
Store1.RefreshData += Store1_RefreshData;
Store1.Proxy.Add(ProxyDatos);
Store1.Reader.Add(jsonr1);
Store2.ID = "Store2";
Store2.AutoLoad = true;
Store2.RefreshData += Store2_RefreshData;
Store2.Proxy.Add(ProxyDatos2);
Store2.Reader.Add(jsonr2);
//barra menu
Toolbar toolbar1 = new Toolbar();
toolbar1.ID = "Toolbar1";
Button button3 = new Button();
button3.Text = "Opciones";
Menu menu1 = new Menu();
MenuItem menuitem1 = new MenuItem();
menuitem1.Text = "Seleccionar Todo";
menuitem1.Listeners.Click.Handler="CountrySelector.addAll(GridPanel1, GridPanel2);";
MenuItem menuitem2 = new MenuItem();
menuitem2.Text = "Quitar Selección";
menu1.Items.Add(menuitem1);
menu1.Items.Add(menuitem2);
button3.Menu.Add(menu1);
toolbar1.Items.Add(button3);
GridPanel gridpanel1 = new GridPanel();
gridpanel1.ID = "GridPanel1";
gridpanel1.EnableDragDrop = false;
gridpanel1.AutoExpandColumn = "desc_show";
gridpanel1.Store.Add(Store1);
gridpanel1.Width = 300;
gridpanel1.Height = 300;
desc_show.Name = "desc_show";
desc_show.Type = RecordFieldType.String;
jsonr1.Fields.Add(desc_show);
Column columna = new Column();
columna.ColumnID = "desc_show";
columna.Header = "Columna 1";
columna.DataIndex = "desc_show";
gridpanel1.ColumnModel.Columns.Add(columna);
CompositeField cfprueba = new CompositeField();
LayoutColumn layoutcomlumna2 = new LayoutColumn();
Panel panel = new Panel();
panel.ID = "Panel2";
panel.Width = 35;
panel.BodyStyle = "background-color: transparent;";
panel.Border = false;
panel.Layout = "Anchor";
Panel panel1 = new Panel();
panel1.Border = false;
panel1.BodyStyle = "background-color: transparent;";
panel1.AnchorVertical = "40%";
Panel panel2 = new Panel();
panel2.ID = "panel2";
panel2.Border = false;
panel2.BodyStyle = "background-color: transparent;";
panel2.Padding = 5;
Button boton = new Button();
boton.Icon = Icon.ResultsetNext;
boton.StyleSpec = "margin-bottom:2px;";
boton.Listeners.Click.Handler="CountrySelector.add();";
ToolTip tooltip1 = new ToolTip();
tooltip1.Title = "Agregar";
tooltip1.Html = "Agregar Filas Seleccionadas";
boton.ToolTips.Add(tooltip1);
Button boton2 = new Button();
boton2.Icon = Icon.ResultsetLast;
boton2.StyleSpec = "margin-bottom:2px;";
boton2.Listeners.Click.Handler="CountrySelector.addAll();";
ToolTip tooltip2 = new ToolTip();
tooltip2.Title = "Agregar Todos";
tooltip2.Html = "Agregar todas las Filas";
boton2.ToolTips.Add(tooltip2);
Button boton3 = new Button();
boton3.Icon = Icon.ResultsetPrevious;
boton3.StyleSpec = "margin-bottom:2px;";
boton3.Listeners.Click.Handler="CountrySelector.remove(GridPanel1, GridPanel2);";
ToolTip tooltip3 = new ToolTip();
tooltip3.Title = "Quitar";
tooltip3.Html = "Quitar Filas Seleccionadas";
boton3.ToolTips.Add(tooltip3);
Button boton4 = new Button();
boton4.Icon = Icon.ResultsetFirst;
boton4.StyleSpec = "margin-bottom:2px;";
boton4.Listeners.Click.Handler="CountrySelector.removeAll(GridPanel1, GridPanel2);";
ToolTip tooltip4 = new ToolTip();
tooltip4.Title = "Quitar Todos";
tooltip4.Html = "Quitar Todas las Filas";
boton4.ToolTips.Add(tooltip4);
panel2.Items.Add(boton);
panel2.Items.Add(boton2);
panel2.Items.Add(boton3);
panel2.Items.Add(boton4);
GridPanel gridpanel2 = new GridPanel();
gridpanel2.ID = "GridPanel2";
gridpanel2.EnableDragDrop = false;
gridpanel2.AutoExpandColumn = "desc_show";
gridpanel2.Store.Add(Store2);
gridpanel2.Width = 300;
gridpanel2.Height = 300;
desc_show2.Name = "desc_show";
desc_show2.Type = RecordFieldType.String;
jsonr2.Fields.Add(desc_show2);
ColumnModel columnamodelo2 = new ColumnModel();
Column columna2 = new Column();
columna2.ColumnID = "Columna2";
columna2.Header = "Columna 2";
columna2.DataIndex = "desc_show";
gridpanel2.ColumnModel.Columns.Add(columna2);
RowSelectionModel rowselection = new RowSelectionModel();
rowselection.ID = "RowSelectionModel2";
cfprueba.Items.Add(gridpanel1);
cfprueba.Items.Add(panel2);
cfprueba.Items.Add(gridpanel2);
window1.TopBar.Add(toolbar1);
window1.Items.Add(cfprueba);
this.form1.Controls.Add(window1);
}
}
}
<%@ Page Language="C#" AutoEventWireup="true" Codebehind="Ejemplo.aspx.cs" Inherits="Project.Ejemplo" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Ejemplo</title>
<script type="text/javascript">
var CountrySelector = {
add : function (source, destination) {
source = source || GridPanel1;
destination = destination || GridPanel2;
if (source.hasSelection()) {
var records = source.store.getSelections();
source.deleteSelected();
Ext.each(records, function(record){
destination.store.addSorted(record);
});
}
},
addAll : function (source, destination) {
source = source || GridPanel1;
destination = destination || GridPanel2;
var records = source.store.getRange();
source.store.removeAll();
Ext.each(records, function(record){
destination.store.addSorted(record);
});
},
remove : function (source, destination) {
this.add(destination, source);
},
removeAll : function (source, destination) {
this.addAll(destination, source);
}
};
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<ext:ResourceManager ID="ResourceManager1" runat="server" />
</div>
</form>
</body>
</html>
thanks,
Last edited by Daniil; Dec 10, 2011 at 5:26 AM.
Reason: Please use [CODE] tags for all code