[CLOSED] GridPanel RowSelectModel don´t working

  1. #1

    [CLOSED] GridPanel RowSelectModel dont working

    Hi...

    I am doing something wrong, probably!

    I declare in my GridPanel the Selection Model as follows

    <SelectionModel>
       <ext:RowSelectionModel runat="server" Mode="Single" />
    </SelectionModel>
    I have a button, called btnDetails, when i call with DirectEvent the protect sub ShowDetails
    <ext:Button runat="server" ID="btnDetails" Icon="ApplicationEdit" Text="Detalhar">
         <DirectEvents>
             <Click OnEvent="ShowDetails" 
                       Failure="Ext.MessageBox.alert('Load failed', 'Error during ajax event!');">
                      <EventMask ShowMask="true" Target="CustomTarget" CustomTarget="={#{grdSugestoes}.body}" />
             </Click> 
         </DirectEvents>
    </ext:Button>
    But, in ShowDetail, the collection SelectedRows allways return 0 in count property, although a selected line in the grid

    Protected Sub ShowDetails(sender As Object, e As Ext.Net.DirectEventArgs)
            Dim sm As Ext.Net.RowSelectionModel = Me.grdSugestoes.GetSelectionModel()
            Dim row As Ext.Net.SelectedRow
            
            If sm.SelectedRows.Count > 0 Then
                row = sm.SelectedRows(0) 'Pode ter mais de uma selecioanda, mas pego a primeira, sempre
                Me.wndSugestoesDetail.Start(Convert.ToInt64(row.RecordID.ToString), grdSugestoes.GetStore())
            Else
                Dim msg As New Ext.Net.MessageBox
                msg.Alert("REGISTRO NO SELECIONADO", "Por favor, selecione um registro na lista para ver o detalhamento!")
                msg.Show()
            End If
                    
        End Sub
    Last edited by Daniil; Jan 24, 2012 at 1:00 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Confirmed, this is a bug. We will investigate.

    Thanks for the report.

    For now, I can suggest to send required data via an extra parameter.

    Example
    <%@ Page Language="C#" %>
     
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <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[] { "test1", "test2", "test3" },
                    new object[] { "test4", "test5", "test6" },
                    new object[] { "test7", "test8", "test9" },
                };
                store.DataBind();
            }
        }
    
        protected void GetSelectedCount(object sender, DirectEventArgs e)
        {
            SelectedRowCollection selectedRows = JSON.Deserialize<SelectedRowCollection>(e.ExtraParams["selection"]);
            X.Msg.Alert("Count", selectedRows.Count).Show();
        }
    </script>
    <!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>Ext.NET v2 Example</title>
    
        <script type="text/javascript">
            var getSelection = function (grid) {
                var selection = grid.getSelectionModel().getSelection(),
                    data = [];
    
                Ext.each(selection, function (r) {
                    data.push({
                        recordID : r.getId()
                    });
                });
                return data;
            };
        </script>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <ext:GridPanel ID="GridPanel1" runat="server" AutoHeight="true">
                <Store>
                    <ext:Store runat="server">
                        <Model>
                            <ext:Model runat="server" IDProperty="test1">
                                <Fields>
                                    <ext:ModelField Name="test1" />
                                    <ext:ModelField Name="test2" />
                                    <ext:ModelField Name="test3" />
                                </Fields>
                            </ext:Model>
                        </Model>
                    </ext:Store>
                </Store>
                <ColumnModel runat="server">
                    <Columns>
                        <ext:Column runat="server" Header="Test1" DataIndex="test1" />
                        <ext:Column runat="server" Header="Test2" DataIndex="test2" />
                        <ext:Column runat="server" Header="Test3" DataIndex="test3" />
                    </Columns>
                </ColumnModel>
                <SelectionModel>
                    <ext:RowSelectionModel runat="server" Mode="Single" />
                </SelectionModel>
            </ext:GridPanel>
            <ext:Button runat="server" Text="Get count of selected rows" OnDirectClick="GetSelectedCount">
                <DirectEvents>
                    <Click OnEvent="GetSelectedCount">
                        <ExtraParams>
                            <ext:Parameter 
                                Name="selection" 
                                Value="getSelection(#{GridPanel1})" 
                                Mode="Raw"
                                Encode="true" />
                        </ExtraParams>
                    </Click>
                </DirectEvents>
            </ext:Button>
        </form>
    </body>
    </html>
  3. #3
    Hi Daniil

    Tested and working fine

    Thanks a lot
  4. #4
    It has been fixed in SVN and will appear in DP2.

    Thanks again for the report.

Similar Threads

  1. [CLOSED] Ext.net v2 Beta release: Top align don´t works
    By supera in forum 2.x Premium Help
    Replies: 2
    Last Post: Mar 16, 2012, 6:53 PM
  2. Replies: 4
    Last Post: Mar 07, 2012, 11:09 AM
  3. Replies: 2
    Last Post: Mar 02, 2012, 2:07 PM
  4. maxLength don´t work
    By reinaldo.designerdigital in forum 1.x Help
    Replies: 3
    Last Post: May 15, 2009, 1:33 PM
  5. My GenericPlugin don´t work with <ext:TextField
    By reinaldo.designerdigital in forum 1.x Help
    Replies: 4
    Last Post: Jan 27, 2009, 3:56 PM

Posting Permissions