[CLOSED] Get multiple RecordID from GridPanel

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] Get multiple RecordID from GridPanel

    I need to get RecordID from GridPanel rows selected... but only the IDProperty field.

    My code:

            <ext:GridPanel runat="server" ID="GridPanelRisultato" MarginSpec="2 0 0 0" Flex="1" Border="true">
                <Store>
                    <ext:Store runat="server" ID="StoreRisultato">
                        <Model>
                            <ext:Model runat="server" IDProperty="CodiceUtente">
                                <Fields>
                                    <ext:ModelField Name="CodiceTipoUtente" Type="String" />
                                    <ext:ModelField Name="CodiceUtente" Type="String" />
                                    <ext:ModelField Name="Cognome" Type="String" />
                                    <ext:ModelField Name="Nome" Type="String" />
                                    <ext:ModelField Name="RagioneSociale" Type="String" />
                                    <ext:ModelField Name="Stato" Type="String" />
                                </Fields>
                            </ext:Model>
                        </Model>
                    </ext:Store>
                </Store>
                <ColumnModel runat="server" EnableColumnHide="False">
                    <Columns>
                        <ext:ComponentColumn runat="server" DataIndex="CodiceTipoUtente" Width="22">
                            <Component>
                                <ext:Image runat="server"  Height="20"/>
                            </Component>
                            <Listeners>
                                <BeforeBind Handler="e.config[0].imageUrl = Ext.net.ResourceMgr.resolveUrl(Ext.String.format('~/Immagini/{0}.png', e.record.data.CodiceTipoUtente));" />
                            </Listeners>
                        </ext:ComponentColumn>
                        <ext:Column runat="server" Text="CodiceUtente" DataIndex="CodiceUtente" Width="100"/>
                        <ext:Column runat="server" Text="Cognome" DataIndex="Cognome" Width="100"/>
                        <ext:Column runat="server" Text="Nome" DataIndex="Nome" Width="100"/>
                        <ext:Column runat="server" Text="RagioneSociale" DataIndex="RagioneSociale" Flex="1"/>
                        <ext:Column runat="server" Text="Stato" DataIndex="Stato" Width="100"/>
                    </Columns>
                </ColumnModel>
                <SelectionModel>
                    <ext:RowSelectionModel runat="server" Mode="Multi" >
                        <DirectEvents>
                            <Select OnEvent="RowSelection_Event" />
                        </DirectEvents>
                    </ext:RowSelectionModel>
                </SelectionModel>
                <Plugins>
                    <ext:FilterHeader runat="server" />
                </Plugins>
            </ext:GridPanel>
        Protected Sub RowSelection_Event(sender As Object, e As Ext.Net.DirectEventArgs)
            Dim Selezione As Ext.Net.RowSelectionModel = TryCast(GridPanelRisultato.GetSelectionModel(), Ext.Net.RowSelectionModel)
    
            Dim Elenco As New StringBuilder()
    
            For Each Riga As Ext.Net.SelectedRow In Selezione.SelectedRows
                Elenco.AppendFormat("RecordID: {0} ", Riga.RecordID)
            Next
    
        End Sub
    If I select two rows, the RowSelectionModel return zero rows !

    Help please
    Last edited by Daniil; Dec 03, 2014 at 8:26 PM. Reason: [CLOSED]
  2. #2
    Hi Mario,

    It appears to be working for me. If I select two rows, it shows "2" for me. Please try the example. Does it work correctly to you? If yes, please provide your full test case that doesn't work.

    Example
    <%@ Page Language="C#" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                Store store = this.GridPanel1.GetStore();
                store.DataSource = new object[] 
                { 
                    new object[] { "test", "test" },
                    new object[] { "test", "test" },
                    new object[] { "test", "test" }
                };
            }
        }
    
        protected void RowSelectionModel_Select(object sender, DirectEventArgs e)
        {
            X.Msg.Alert("RowSelectionModel_Select", (GridPanel1.GetSelectionModel() as RowSelectionModel).SelectedRows.Count).Show();
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
    
            <ext:GridPanel ID="GridPanel1" runat="server">
                <Store>
                    <ext:Store runat="server">
                        <Model>
                            <ext:Model runat="server">
                                <Fields>
                                    <ext:ModelField Name="test1" />
                                    <ext:ModelField Name="test2" />
                                </Fields>
                            </ext:Model>
                        </Model>
                    </ext:Store>
                </Store>
                <ColumnModel runat="server">
                    <Columns>
                        <ext:Column runat="server" Text="Test 1" DataIndex="test1" />
                        <ext:Column runat="server" Text="Test 2" DataIndex="test2" />
                    </Columns>
                </ColumnModel>
                <SelectionModel>
                    <ext:RowSelectionModel runat="server" Mode="Multi">
                        <DirectEvents>
                            <Select OnEvent="RowSelectionModel_Select" />
                        </DirectEvents>
                    </ext:RowSelectionModel>
                </SelectionModel>
            </ext:GridPanel>
        </form>
    </body>
    </html>
  3. #3
    If you run the example in a UserControl not works !


    WebForm1.aspx
    <%@ Page Language="vb" AutoEventWireup="true" CodeBehind="WebForm1.aspx.vb" Inherits="WebApplication2.WebForm1" %>
    
    <%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>
    
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
    
        <ext:ResourceManager runat="server" />
    
        <ext:Viewport runat="server">
            <LayoutConfig>
                <ext:VBoxLayoutConfig Align="Center" />
            </LayoutConfig>
    
            <Items>
                <ext:Panel ID="PanelApplicazione" runat="server" Flex="1" Width="1000" Border="false" PaddingSpec="5 0 5 0" Layout="FitLayout" />
            </Items>
    
        </ext:Viewport>
    
        </form>
    </body>
    </html>
    WebForm1.aspx.vb
    Public Class WebForm1
        Inherits System.Web.UI.Page
    
        Protected Sub Page_Load(sender As Object, e As EventArgs)
            Dim Applicazione As New Ext.Net.UserControlLoader
            Applicazione.Path = "WebUserControl1.ascx"
            PanelApplicazione.Items.Clear()
            PanelApplicazione.Items.Add(Applicazione)
        End Sub
    
    End Class
    WebUserControl1.ascx
    <%@ Control Language="vb" AutoEventWireup="true" CodeBehind="WebUserControl1.ascx.vb" Inherits="WebApplication2.WebUserControl1" %>
    
    <ext:GridPanel ID="GridPanel1" runat="server">
        <Store>
            <ext:Store runat="server">
                <Model>
                    <ext:Model runat="server">
                        <Fields>
                            <ext:ModelField Name="test1" />
                            <ext:ModelField Name="test2" />
                        </Fields>
                    </ext:Model>
                </Model>
            </ext:Store>
        </Store>
        <ColumnModel runat="server">
            <Columns>
                <ext:Column runat="server" Text="Test 1" DataIndex="test1" />
                <ext:Column runat="server" Text="Test 2" DataIndex="test2" />
            </Columns>
        </ColumnModel>
        <SelectionModel>
            <ext:RowSelectionModel runat="server" Mode="Multi">
                <DirectEvents>
                    <Select OnEvent="RowSelectionModel_Select" />
                </DirectEvents>
            </ext:RowSelectionModel>
        </SelectionModel>
    </ext:GridPanel>
    WebUserControl1.ascx.vb
    Public Class WebUserControl1
        Inherits System.Web.UI.UserControl
    
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            If Not Ext.Net.X.IsAjaxRequest Then
                Dim store As Ext.Net.Store = Me.GridPanel1.GetStore()
                store.DataSource = New Object() {New Object() {"test", "test"}, New Object() {"test", "test"}, New Object() {"test", "test"}}
            End If
        End Sub
    
        Protected Sub RowSelectionModel_Select(sender As Object, e As Ext.Net.DirectEventArgs)
            Ext.Net.X.Msg.Alert("RowSelectionModel_Select", TryCast(GridPanel1.GetSelectionModel(), Ext.Net.RowSelectionModel).SelectedRows.Count).Show()
        End Sub
    
    End Class
  4. #4
    Please replace "Page_Load" with "Page_Load". It should start working.

    I would also recommend to set explicit IDs.

    For the user control:
    Applicazione.UserControlID = "WebUserControl1"
    For the RowSelectionModel also.
    <ext:RowSelectionModel ID="RowSelectionModel1" runat="server">
  5. #5
    Danill,

    you wrote...

    Please replace "Page_Load" with "Page_Load"
    What ?
    :)
  6. #6
    Sorry. Page_Load with Page_Init.
  7. #7
    I have replaced "Page_Load" with "Page_Init"...
    and assigned an ID valid to Objects...
    but not works... :(

    Danill, please can you try to run my code and test on it?
    Very very tnx !

    mario
  8. #8
    Yes, actually I tried my suggestion before suggesting it to you. The only thing that I needed to get your code working is replacing "Page_Load" with "Page_Init".
  9. #9
    I am distraught !

    In this location:

    http://dropcanvas.com/aw79o

    there is a ZIP file with the complete solution of the test with all the files and settings (except EXT.NET bin files)
    Can you try on this code ?

    Tnx
  10. #10
    Sorry, I was not clear enough. Please replace Page_Load with Page_Init in the page, not in the user control.
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 1
    Last Post: Jul 02, 2013, 8:48 AM
  2. Replies: 1
    Last Post: Jun 26, 2013, 4:00 PM
  3. [CLOSED] Get RecordID of Newly Added Row
    By hemantpatil in forum 2.x Premium Help
    Replies: 5
    Last Post: Mar 15, 2013, 7:30 AM
  4. Replies: 1
    Last Post: Jun 08, 2011, 4:11 AM
  5. [CLOSED] RecordID in GridPanel
    By Jurke in forum 1.x Premium Help
    Replies: 2
    Last Post: Oct 08, 2008, 10:02 AM

Tags for this Thread

Posting Permissions