getRowsValues doesn't work

  1. #1

    getRowsValues doesn't work

    Hi all,

    I want to get selected rows from gridpanel. When i try to use getRowsValues it doesn't work. This is the chronologies :
    1. In the child page (.ascx), i've made one public property that return grid panel :
    // MyUserControl.ascx
    public GridPanel GetGridFromUserControl
            {
                get { return this.grdPnlAccessViewList; }
            }
    2. And in parent page (.aspx), i've tried to get data from that gridpanel by calling GetMyGrid.
    // ParentPage.aspx
    <ext:LinkButton ID="lnkBtnSubmit" runat="server" Text="Submit" Icon="ApplicationAdd" X="-50">
                                        <DirectEvents>
                                            <Click OnEvent="lnkBtnSubmit_Click">
                                                <ExtraParams>
                                                    <ext:Parameter Name="Grid1" Value="Ext.encode(#{this.GetMyGrid }.getRowsValues({selectedOnly : false}))" Mode="Raw" />
                                                </ExtraParams>
                                            </Click>
                                        </DirectEvents>
                                    </ext:LinkButton>
     private GridPanel GetMyGrid { get { return this.vwBrowsePage.GetGridFromUserControl; } }
    protected void lnkBtnSubmit_Click(object sender, DirectEventArgs e) 
        {
            wndwBrowseAccessPage.Hide();
    
            //JSON representation
            string gridJson = e.ExtraParams["Grid1"];
         
            //XML representation
            System.Xml.XmlNode grid1Xml = JSON.DeserializeXmlNode("{records:{record:" + gridJson + "}}");
    
            //array of Dictionaries
            Dictionary<string, string>[] grid1Data = JSON.Deserialize<Dictionary<string, string>[]>(gridJson);
            if (grid1Data != null) { }
        }
    When the link button clicked, it doesn't work. Anyone can help me please ? Thanks
  2. #2
    1. ' it doesn't work.' doesn't describe the issue at all. Please always provide more details about issues (request is not initiated, request is initiated but extra parameter is empty or javascript error)

    2. Please always provide simple runable example (instead parts of code), it will help us to resolve an issue quickly

    3. Instead '(#{this.GetMyGrid }' use '#{GetMyGrid}'
  3. #3
    Quote Originally Posted by Vladimir View Post
    1. ' it doesn't work.' doesn't describe the issue at all. Please always provide more details about issues (request is not initiated, request is initiated but extra parameter is empty or javascript error)

    2. Please always provide simple runable example (instead parts of code), it will help us to resolve an issue quickly

    3. Instead '(#{this.GetMyGrid }' use '#{GetMyGrid}'
    Hi Vladimir,

    Thanks for fast response ya,

    1. ' it doesn't work.' doesn't describe the issue at all. Please always provide more details about issues (request is not initiated, request is initiated but extra parameter is empty or javascript error)
    I think the error was occur from this line :
    <ext:Parameter Name="Grid1" Value="Ext.encode(#{this.GetMyStore}.getRecordsValues({selectedOnly : false}))" Mode="Raw" />
    Especially in this code :
    #{this.GetMyStore}
    I've tried your suggest to change #{this.GetMyStore} ==> #{GetMyStore}, but it still doesn't work. :(


    2. Please always provide simple runable example (instead parts of code), it will help us to resolve an issue quickly
    This is for the real code :
    // ViewControl.ascx
    namespace Ext.Net.Examples.Pages.AccessManagement.AccessView
    {
        public partial class ViewControl : System.Web.UI.UserControl
        {
            private static Logger logger = LogManager.GetCurrentClassLogger();
    
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!X.IsAjaxRequest)
                {
                    this.BindData();
                }
            }
            protected void DataRefreshAccessView(object sender, StoreReadDataEventArgs e)
            {
                this.BindData();
            }
            
            private void BindData()
            {
                Store store = this.grdPnlAccessViewList.GetStore();
    
                store.DataSource = this.GetData;
                store.DataBind();
            }
            private System.Data.DataTable GetData
            {
                get
                {
                    return new Framework.Model.DbManager()
                        .SelectRows("Select * from t_access where AccessPage <> '#'");
                }
            }
    
            [DirectMethod]
            public void UnCheckAllData()
            {
                using (var sm = grdPnlAccessViewList.SelectionModel.Primary 
                    as CheckboxSelectionModel) sm.DeselectAll();
            }
    
            #region Accessors
            public GridPanel GetMyGrid
            {
                get { return this.grdPnlAccessViewList; }
            }
            public Store GetStore
            {
                get { return this.Store1; }
            }
            #endregion
        }
    }
    This is for parent page (Default.aspx)
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Ext.Net.Examples.Pages.GroupManagement.CRUDGRoup.RoleAdd.Default" %>
    
    <%@ Register src="../../../AccessManagement/AccessView/ViewControl.ascx" tagname="ViewControl" tagprefix="uc1" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <script runat="server">
        protected void lnkCloseWndw_Click(object sender, DirectEventArgs e) 
        {
            wndwBrowseAccessPage.Hide();
        }
    
        private GridPanel GetMyGrid { get { return this.vwBrowsePage.GetMyGrid; } }
        private Store GetMyStore 
        {
            get { return vwBrowsePage.GetStore; }
        }
    
        protected void lnkBtnSubmit_Click(object sender, DirectEventArgs e) 
        {
            wndwBrowseAccessPage.Hide();
            
            //Access Grid contains data from user control
            //var myGrid = vwBrowsePage.GetMyGrid;
    
            //JSON representation
            string gridJson = e.ExtraParams["Grid1"];
            //var extraParams = new Ext.Net.ParameterCollection();
            //extraParams.Add(new Ext.Net.Parameter()
            //{
            //    Name = "Grid1",
            //    Value = "Ext.encode(#{GetMyGrid.id}.getRowsValues({selectedOnly : false}))",
            //    Mode = ParameterMode.Raw
            //});
            //string gridJson = new DirectEventArgs(extraParams).ExtraParams["Grid1"];
    
            //XML representation
            System.Xml.XmlNode grid1Xml = JSON.DeserializeXmlNode("{records:{record:" + gridJson + "}}");
    
            //array of Dictionaries
            Dictionary<string, string>[] grid1Data = JSON.Deserialize<Dictionary<string, string>[]>(gridJson);
            if (grid1Data != null) { }
        }
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Add Role</title>
        <link href="/resources/css/examples.css" rel="stylesheet" type="text/css" />
        <style runat="server" type="text/css">
            .Style1
            {
                margin-right:10px;
            }
            .StyleWndw
            {
                margin-top:80px;
                margin-left:150px;
            }
        </style>
    </head>
    <body>
    <ext:ResourceManager ID="ResourceManager1" runat="server" DirectMethodNamespace="RoleDirectMethodX" />
        <form id="frmAddRole" runat="server">
        <div>
            <ext:Panel 
                ID="pnlHeader"
                runat="server"
                Border="true"
                Height="40"
                Width="500"
                BodyStyle="background-color:#CCE5FF;"
                Html="<center><f1>Add New Role</f1></center>" />
        </div>
        <div>
            <ext:Panel
                ID="pnlContent"
                runat="server"
                Width="500"
                ButtonAlign="Right"
                BodyPadding="5"
                Region="Center" 
                >
                <Items>
                    <ext:TextField runat="server" ID="txtId" FieldLabel="Group Id " ReadOnly="true"/>
                    <ext:TextField runat="server" ID="txtDesc" FieldLabel="Group Name " AutoFocus="true" />
                    <ext:TextField runat="server" ID="txtGroupAccess" FieldLabel="Group Access " ReadOnly="true" />
                    <ext:Button runat="server" ID="btnBrowseAccessPage" Text="..." X="260" Y="-27" ToolTip="Browse Access">
                        <Listeners>
                            <Click Handler="#{wndwBrowseAccessPage}.show(this);" />
                        </Listeners>
                    </ext:Button>
                    <ext:Window runat="server" Hidden="true"
                            ID="wndwBrowseAccessPage" Title="Page Accesses" 
                            Icon="House"
                            MinWidth="800"
                            MinHeight="348"
                            Modal="true"
                            Cls="StyleWndw"
                            >
                        <Content>
                            <uc1:ViewControl ID="vwBrowsePage" runat="server" />
                            <ext:ButtonGroup runat="server" ButtonAlign="Right">
                                <Buttons>
                                    <ext:LinkButton ID="lnkBtnSubmit" runat="server" Text="Submit" Icon="ApplicationAdd" X="-50">
                                        <DirectEvents>
                                            <Click OnEvent="lnkBtnSubmit_Click">
                                                <ExtraParams>
                                                    <ext:Parameter Name="Grid1" Value="Ext.encode(#{this.GetMyStore}.getRecordsValues({selectedOnly : false}))" Mode="Raw" />
                                                </ExtraParams>
                                            </Click>
                                        </DirectEvents>
                                    </ext:LinkButton>
                                    <ext:LinkButton ID="lnkBtnCancel" runat="server" Text="Cancel All" Icon="Cancel" X="-50">
                                        <Listeners>
                                            <Click Handler="RoleDirectMethodX.vwBrowsePage.UnCheckAllData();" />
                                        </Listeners>
                                    </ext:LinkButton>
                                    <ext:LinkButton ID="lnkCloseWndw" runat="server" Text="Close Window" Icon="ApplicationGo" Cls="Style1">
                                        <Listeners>
                                            <Click Handler="#{wndwBrowseAccessPage}.hide();" />
                                        </Listeners>
                                    </ext:LinkButton>
                                </Buttons>
                            </ext:ButtonGroup>
                        </Content>
                    </ext:Window>
                </Items>
                <Buttons>
                    <ext:LinkButton ID="LinkButton1" runat="server" Icon="Disk" Text="Save New Role">
                        <DirectEvents>
                            <Click OnEvent="btnSave_Click" />
                        </DirectEvents>
                    </ext:LinkButton>
                    <ext:LinkButton ID="LinkButton2" runat="server" Icon="Erase" Text="Clear">
                        <DirectEvents>
                            <Click OnEvent="btnClear_Click" />
                        </DirectEvents>
                    </ext:LinkButton>
                </Buttons>
            </ext:Panel>
        </div>
        </form>
    </body>
    </html>
    3. Instead '(#{this.GetMyGrid }' use '#{GetMyGrid}'
    [/QUOTE]
    It still doesn't work :(

    Thanks
  4. #4
    I don't see a grid in your sample. What ID of the grid? Inside #{} you have to use ID
  5. #5
    Quote Originally Posted by Vladimir View Post
    I don't see a grid in your sample. What ID of the grid? Inside #{} you have to use ID
    Hi Vladimir,
    The grid panel i made inside ViewControl.ascx, this is for the code :

    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ViewControl.ascx.cs" Inherits="Ext.Net.Examples.Pages.AccessManagement.AccessView.ViewControl" %>
    
    <div>
        <ext:Panel 
            ID="pnlHeader"
            runat="server"
            Border="false"
            Height="40"
            Flex="1"  
            Width="800"
            BodyStyle="background-color:#CCE5FF;"
            Html="<center><f1>Access Page List</f1></center>">
        </ext:Panel>
    </div>
    <div>
        <ext:Panel
            ID="pnlContent"
            runat="server"
            ButtonAlign="Left"
            >
            <Items>
                <ext:GridPanel 
                    runat="server"
                    ID="grdPnlAccessViewList"
                    AutoHeight="true"
                    MinHeight="250"
                    Border="false"
                    >
                    <Store>
                        <ext:Store
                            ID="Store1"
                            runat="server"
                            OnRefreshData="DataRefreshAccessView"
                            PageSize="10">
                            <Model>
                                <ext:Model ID="Model1" runat="server">
                                    <Fields>
                                        <ext:ModelField Name="AccessId" Type="String" />
                                        <ext:ModelField Name="AccessName" Type="String" />
                                        <ext:ModelField Name="AccessPage" Type="String" />
                                    </Fields>
                                </ext:Model>
                            </Model>
                                
                        </ext:Store>
                    </Store>
                    <ColumnModel ID="ColumnModel1" runat="server">
                        <Columns>
                            <ext:Column ID="Column1" runat="server" Text="Access Id" DataIndex="AccessId" Flex="1" />
                            <ext:Column ID="Column2" runat="server" Text="Access Name" DataIndex="AccessName" Flex="1"/>
                            <ext:Column ID="Column3" runat="server" Text="Access Url" DataIndex="AccessPage" Flex="1"/>
                        </Columns>
                    </ColumnModel>
                    <SelectionModel>
                        <ext:CheckboxSelectionModel runat="server" Mode="Multi" ID="cmbDataUser"/>
                    </SelectionModel>
                    <%--<View>
                        <ext:GridView runat="server" StripeRows="true" />                   
                    </View>
                    <BottomBar>
                     <ext:PagingToolbar ID="PagingToolbar1" runat="server">
                        <Items>
                            <ext:Label ID="Label1" runat="server" Text="Page size:" />
                            <ext:ToolbarSpacer ID="ToolbarSpacer1" runat="server" Width="5" />
                            <ext:ComboBox ID="ComboBox1" runat="server" Width="80">
                                <Items>
                                    <ext:ListItem Text="1" />
                                    <ext:ListItem Text="5" />
                                    <ext:ListItem Text="10" />
                                    <ext:ListItem Text="15" />
                                    <ext:ListItem Text="20" />
                                </Items>
                                <SelectedItems>
                                    <ext:ListItem Value="5" />
                                </SelectedItems>
                                <Listeners>
                                    <Select Handler="#{grdPnlAccessViewList}.store.pageSize = parseInt(this.getValue(), 5); #{grdPnlAccessViewList}.store.reload();" />
                                </Listeners>
                            </ext:ComboBox>
                        </Items>
                        <Plugins>
                            <ext:ProgressBarPager ID="ProgressBarPager1" runat="server" />
                        </Plugins>
                    </ext:PagingToolbar>
                </BottomBar>--%>
                </ext:GridPanel>
            </Items>
        </ext:Panel>
    </div>
    Thanks
  6. #6
    In this case, you need to use #{grdPnlAccessViewList}
  7. #7
    Quote Originally Posted by Vladimir View Post
    In this case, you need to use #{grdPnlAccessViewList}
    It still doesn't work at all Vladimir.. :( Btw, thanks for your response ya.. :) Nice try..
  8. #8
    What do you mean 'doesn't work'? Do you have js errors or parameter is empty on the server side?
  9. #9
    Quote Originally Posted by Vladimir View Post
    What do you mean 'doesn't work'? Do you have js errors or parameter is empty on the server side?
    I'm not sure if there is any error occur in js. May be with this picture can explain you more clearly.
    1. Parent page shown like this :
    Click image for larger version. 

Name:	Parent Page.PNG 
Views:	147 
Size:	31.5 KB 
ID:	5405

    2. When the button browse clicked, child page show up :
    Click image for larger version. 

Name:	Child Page.jpg 
Views:	162 
Size:	60.3 KB 
ID:	5406

    What do you mean 'doesn't work'?
    3. I choose two rows for the sample from the grid panel, and then when the submit button clicked there is no something happened.

    4 The goal of this code is getting selected rows from that panel.

    Thanks
  10. #10
    Quote Originally Posted by Vladimir View Post
    What do you mean 'doesn't work'? Do you have js errors or parameter is empty on the server side?
    Hey.. :D it works..!! :D I don't know what happened, may be there is a typo.
    This is for the code :
    <Click OnEvent="lnkBtnSubmit_Click">
              <ExtraParams>
                    <ext:Parameter Name="Grid1" Value="Ext.encode(#{grdPnlAccessViewList}.getRowsValues({selectedOnly : true}))" Mode="Raw" />
               </ExtraParams>
    </Click>
    Thank you Vladimir :) Please change it as a SOLVED thread :)

Similar Threads

  1. The Cls on <Menu> doesn't work
    By cjt0226 in forum 2.x Help
    Replies: 1
    Last Post: May 16, 2013, 6:39 AM
  2. Project Ext.Net.UX doesn't work.
    By flaviodamaia in forum 2.x Help
    Replies: 6
    Last Post: Nov 01, 2012, 1:41 PM
  3. Doesn't work via SSLVPN
    By inorder in forum 1.x Help
    Replies: 10
    Last Post: Jun 06, 2012, 7:42 AM
  4. Northwind example doesn't work in IE9
    By Const in forum 1.x Help
    Replies: 10
    Last Post: Dec 09, 2011, 3:04 AM
  5. [1.0RC]MultiHeader doesn't work.
    By firebank in forum 1.x Help
    Replies: 1
    Last Post: Nov 11, 2010, 4:06 PM

Posting Permissions