two grids rows

  1. #1

    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 :

    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
  2. #2
    Hi,

    You should add a RowSelectionModel to GridPanel's SelectionModel.
    GridPanel1.SelectionModel.Add(new RowSelectionModel());
  3. #3

    not work

    Quote Originally Posted by Daniil View Post
    Hi,

    You should add a RowSelectionModel to GridPanel's SelectionModel.
    GridPanel1.SelectionModel.Add(new RowSelectionModel());


    I tried and does not work
    :(
  4. #4
    Did you add the same thing for the GridPanel2 as well?

    Could you extend your example with some dummy data for stores to allow us to run it locally on our side and reproduce the error?
  5. #5

    example

    example, thanks ,


    
    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)
            {
                this.Store1.DataSource = new object[]
                {
                    new object[] {"3m Co", 71.72},
                    new object[] {"Alcoa Inc", 29.01},
                    new object[] {"Altria Group Inc", 83.81}
                };
    
                this.Store1.DataBind();
                
                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;
    
                desc_show.Name = "company";
    
                ArrayReader p_array = new ArrayReader();
    
                Store1.ID = "Store1";
                
                Store1.Reader.Add(p_array);
    
                p_array.Fields.Add(desc_show);    
               
                Store2.ID = "Store2";
                Store2.AutoLoad = true;
    
                ArrayReader p_array2 = new ArrayReader();
                
                desc_show2.Name = "company";      
    
                p_array2.Fields.Add(desc_show2);
                
                Store2.Reader.Add(p_array2);
    
                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 = "nombre";
                gridpanel1.Store.Add(Store1);
                
                gridpanel1.Width = 300;
                gridpanel1.Height = 300;                     
    
                Column columna = new Column();
                columna.ColumnID = "nombre";
                columna.Header = "Columna 1";
                columna.DataIndex = "company";
                
                gridpanel1.ColumnModel.Columns.Add(columna);
    
                RowSelectionModel rowSelectionModel = new RowSelectionModel();
    
                gridpanel1.SelectionModel.Add(rowSelectionModel);
    
                GridFilters gridfilter1 = new GridFilters();
    
                StringFilter stringfilter1 = new StringFilter();
                stringfilter1.DataIndex = "nombre";
    
                gridfilter1.Filters.Add(stringfilter1);
    
                gridpanel1.Plugins.Add(gridfilter1);
                
                CompositeField cfprueba = new CompositeField();
              
                LayoutColumn layoutcomlumna2 = new LayoutColumn();
    
                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 = "Columna2";
                gridpanel2.Store.Add(Store2);
                gridpanel2.Width = 300;
                gridpanel2.Height = 300;
    
                ColumnModel columnamodelo2 = new ColumnModel();
    
                Column columna2 = new Column();
                columna2.ColumnID = "Columna2";
                columna2.Header = "Columna 2";
                columna2.DataIndex = "company";
    
                gridpanel2.ColumnModel.Columns.Add(columna2);
    
                RowSelectionModel rowselection = new RowSelectionModel();
                rowselection.ID = "RowSelectionModel2";
    
                gridpanel2.SelectionModel.Add(rowselection);
    
                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.getRange();
                        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>
  6. #6
    The page appears to be working correctly for me.

    Please clarify what are the steps to reproduce the problem?
  7. #7

    response

    Quote Originally Posted by Daniil View Post
    The page appears to be working correctly for me.

    Please clarify what are the steps to reproduce the problem?


    when I select an item and want to pass it to gridpanel right
    I spend every item,
    It's the same from the gridpanel right to pass values ​​to the left gridpanel.
    if I just want to pass values ​​from one does not work.
    have any idea what I'm doing wrong

    thanks

    Alexa.
  8. #8
    Please replace
    var records = source.store.getRange();
    with
    var records = source.selModel.getSelections();
    in the CountrySelector.add function.
  9. #9

    thanks

    Quote Originally Posted by Daniil View Post
    Please replace
    var records = source.store.getRange();
    with
    var records = source.selModel.getSelections();
    in the CountrySelector.add function.


    Perfect!!! thanks a lot :)

Similar Threads

  1. [CLOSED] GridPanel.Rows.Changing Background Color of Rows
    By supera in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Mar 01, 2012, 5:18 PM
  2. Replies: 1
    Last Post: Oct 13, 2010, 11:09 PM
  3. Two Grids get value
    By JsonTerre in forum 1.x Help
    Replies: 0
    Last Post: Mar 09, 2009, 11:04 PM
  4. Move rows between grids
    By fquintero in forum 1.x Help
    Replies: 11
    Last Post: Jan 20, 2009, 10:06 AM
  5. DnD Between 2 Grids
    By davidhoyt in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jan 13, 2009, 2:02 AM

Tags for this Thread

Posting Permissions