[CLOSED] error in gridpanel with reconfigure

  1. #1

    [CLOSED] error in gridpanel with reconfigure

    I load a grid by code behind using reconfigure with List (Of columnBase ) . In the construction of columns , I declare the filter of the same coluna.Filter.Add(New Ext.Net.StringFilter) .

    In the first loading of the page filter works normally, but when I click a button that will get the data back , the filters do not work anymore.


     Public Sub popularGridValores()
    
            Try
    
                cr.dataDe = ctrDataInicio.SelectedDate.ToString("yyyyMMdd")
                cr.dataAte = ctrDataFim.SelectedDate.ToString("yyyyMMdd")
                cr.agrupamento = cbbAgrupamento.SelectedItem.Value
    
                cr.pergunta = IIf(Me.cbbPergunta.SelectedItem.Value = Nothing, "", Me.cbbPergunta.SelectedItem.Value.Trim)
    
    
                cr.pergunta = IIf(Me.cbbPergunta.SelectedItem.Value = Nothing, "", Me.cbbPergunta.SelectedItem.Value.Trim)
    
                cr.campo = IIf(Me.cbbFiltrosParametrizados.SelectedItem.Value = Nothing, "", Me.cbbFiltrosParametrizados.SelectedItem.Value)
                cr.itemPesquisa = IIf(Me.cbbFiltrarPadrao.SelectedItem.Value = Nothing, "", Me.cbbFiltrarPadrao.SelectedItem.Value)
    
    
                cr.DescricaoCampo = cbbAgrupamento.SelectedItem.Text
                cr.grupo = IIf(cbbGrupoOcorrencia.SelectedItem.Value Is Nothing, "0", cbbGrupoOcorrencia.SelectedItem.Value)
                cr.tipo = IIf(cbbTipoOcorrencia.SelectedItem.Value Is Nothing, "0", cbbTipoOcorrencia.SelectedItem.Value)
                cr.classificacao = IIf(cbbClassOcorrencia.SelectedItem.Value Is Nothing, "0", cbbClassOcorrencia.SelectedItem.Value)
    
    
                cr.campoId = BuscarCampoId()
    
                If cr.campoId Is Nothing Then
                    cr.campoId = ""
                End If
    
    
                If cr.dataDe = "00010101" Or cr.dataAte = "00010101" Then
                    Dim ano = Date.Now.Year
                    cr.dataDe = ano.ToString + "0401"
                    'cr.dataDe = "20150415"
                    cr.dataAte = Date.Now
                    cr.dataAte = cr.dataAte.ToDateString
    
                End If
    
                dt = cr.PopularDadosGridValores
    
                Dim dt2 As New DataTable
                dt2 = dt.Copy
    
                Dim tamanhoDt As Integer
    
                Dim numeroModels As String = "1"
                Dim numeroLinhas As Integer
    
                tamanhoDt = dt.Columns.Count
                numeroLinhas = dt.Rows.Count
    
                For indiceRemover = tamanhoDt - 1 To 3 Step -1
                    dt.Columns.RemoveAt(indiceRemover)
                Next
    
                For indiceAdicionar As Integer = 3 To tamanhoDt - 1
                    dt.Columns.Add(dt2.Columns(indiceAdicionar).ColumnName, Type.GetType("System.Double"))
                    dt.Columns.Add("ColunaLink/" & contadorNovaColuna.ToString)
                    contadorNovaColuna = contadorNovaColuna + 1
                Next
    
                Dim tamanhoDt2 As Integer = dt2.Columns.Count
                tamanhoDt = dt.Columns.Count
    
                Dim indiceColunaDt2 As Integer = 3
                For indiceColuna As Integer = 3 To tamanhoDt - 1
    
    
                    Dim ano As String
                    Dim mes As String
                    Dim valor As String = ""
    
                    ano = dt2.Columns(indiceColunaDt2).ColumnName.Split("/")(0)
                    mes = dt2.Columns(indiceColunaDt2).ColumnName.Split("/")(1)
    
                    If IsNumeric(ano) Then
    
                    End If
    
                    For indiceLinha As Integer = 0 To numeroLinhas - 1
    
                        valor = dt2(indiceLinha)(indiceColunaDt2)
                        valor = Format(Convert.ToDouble(valor), "c").Trim
                        valor = valor.Replace("R$", "")
                        valor = valor.Replace(" ", "")
                        'valor = valor.Replace("R$", "").Replace(".", "").Replace(",", "")
    
                        Dim url = "/SOC/RELATORIOS/" & dt2(indiceLinha)("link") & "&D=" & ano & mes & "&CP=" & cr.campo & "&I=" & cr.itemPesquisa & "&CI=" & cr.campoId & "&DI=" & dt2(indiceLinha)(0).ToString.Replace(" ", "@") & "&G=" & cr.grupo & "&TQ=" & cr.tipo & "&CQ=" & cr.classificacao
    
                        dt(indiceLinha)(indiceColuna) = valor
                        dt(indiceLinha)(indiceColuna + 1) = url
    
                    Next
    
                    indiceColuna = indiceColuna + 1
                    indiceColunaDt2 = indiceColunaDt2 + 1
                Next
    
                For i As Integer = 0 To tamanhoDt - 2
    
                    Me.popularModel(dt.Columns(i).ColumnName, dt.Columns(i + 1).ColumnName, i)
    
                Next
    
                gridOcorrenciaMes.Reconfigure(lista)
    
                Me.popularStore()
    
            Catch ex As Exception
    
            End Try
    
    
        End Sub
    
    
     Public Sub popularModel(ByVal nomeModel As String, ByVal nomeColunaLink As String, ByVal indice As Integer)
    
            Try
    
                Dim tipoAgrup As String = cbbAgrupamento.SelectedItem.Value
    
                Dim colunaMes As String = nomeModel.Split("/")(0)
    
                If indice <= 1 And tipoAgrup = "CTT_DESC01" Or indice = 1 And tipoAgrup <> "CTT_DESC01" Then
                    Me.AddField(New ModelField(nomeModel.ToString))
                    Dim coluna As New Ext.Net.Column
    
                    If indice = 1 Then
                        coluna.Flex = 5
                    Else
                        coluna.Flex = 1
                    End If
    
                    coluna.ID = "Col" & nomeModel.Replace("/", "").Replace(" ", "").Replace("\", "")
                    coluna.Text = nomeModel
                    coluna.DataIndex = nomeModel
                    coluna.Filterable = True
                    coluna.Filter.Add(New Ext.Net.StringFilter)
    
                    lista.Add(coluna)
    
                ElseIf IsNumeric(colunaMes) Then
                    Me.AddField(New ModelField(nomeModel.ToString))
                    Dim hyperColumn As New Ext.Net.HyperlinkColumn
    
                    hyperColumn.Flex = 2
                    hyperColumn.Align = Alignment.Center
                    hyperColumn.ID = "Col" & nomeModel.Replace("/", "").Replace(" ", "").Replace("\", "")
                    hyperColumn.Text = nomeModel
                    hyperColumn.DataIndex = nomeModel
                    hyperColumn.Filterable = True
                    hyperColumn.Cls = "hypCol"
                    hyperColumn.Flex = 1
                    hyperColumn.DataIndexHref = nomeColunaLink
                    hyperColumn.Renderer.Fn = "linkColumn"
    
                    lista.Add(hyperColumn)
    
                End If
    
                contador += 1
    
            Catch ex As Exception
    
            End Try
    
        End Sub
    Last edited by Daniil; Aug 05, 2015 at 2:51 PM. Reason: [CLOSED]
  2. #2
    The error still happens
    Last edited by miltonfoti; Jul 29, 2015 at 6:15 PM.
  3. #3
    Hi @miltonfoti,

    Unfortunately, I cannot run your code and I cannot reproduce it with my test case that I posted below. Please provide us with a similar standalone .aspx page that would reproduce the problem. Useful tips on posting test cases you can find here:
    Forum Guidelines For Posting New Topics

    Example
    <%@ Page Language="C#" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                this.Store1.DataSource = this.Data;
            }
        }
    
        protected void Reconfigure(object sender, DirectEventArgs e)
        {
            this.GridPanel1.Reconfigure(new Column[] { 
                new Column 
                { 
                    DataIndex = "company",
                    Text = "Company",
                    Flex = 1,
                    Filter = 
                    {
                        new StringFilter()
                    } 
                } 
            });
        }
    
        private object Data
        {
            get
            {
                return new List<object>
                {
                   new { company = "3m Co", price = 71.72, change = 0.02, pctChange = 0.03, lastChange = "9/1 12:00am" },
                   new { company = "Alcoa Inc", price = 29.01, change = 0.42, pctChange = 1.47, lastChange = "9/1 12:00am" },
                   new { company = "Altria Group Inc", price = 83.81, change = 0.28, pctChange = 0.34, lastChange = "9/1 12:00am" },
                   new { company = "American Express Company", price = 52.55, change = 0.01, pctChange = 0.02, lastChange = "9/1 12:00am" },
                   new { company = "American International Group, Inc.", price = 64.13, change = 0.31, pctChange = 0.49, lastChange = "9/1 12:00am" },
                   new { company = "AT&T Inc.", price = 31.61, change = -0.48, pctChange = -1.54, lastChange = "9/1 12:00am" },
                   new { company = "Boeing Co.", price = 75.43, change = 0.53, pctChange = 0.71, lastChange = "9/1 12:00am" },
                   new { company = "Caterpillar Inc.", price = 67.27, change = 0.92, pctChange = 1.39, lastChange = "9/1 12:00am" },
                   new { company = "Citigroup, Inc.", price = 49.37, change = 0.02, pctChange = 0.04, lastChange = "9/1 12:00am" },
                   new { company = "E.I. du Pont de Nemours and Company", price = 40.48, change = 0.51, pctChange = 1.28, lastChange = "9/1 12:00am" },
                   new { company = "Exxon Mobil Corp", price = 68.1, change = -0.43, pctChange = -0.64, lastChange = "9/1 12:00am" },
                   new { company = "General Electric Company", price = 34.14, change = -0.08, pctChange = -0.23, lastChange = "9/1 12:00am" },
                   new { company = "General Motors Corporation", price = 30.27, change = 1.09, pctChange = 3.74, lastChange = "9/1 12:00am" },
                   new { company = "Hewlett-Packard Co.",  price = 36.53, change = -0.03, pctChange = -0.08, lastChange = "9/1 12:00am" },
                   new { company = "Honeywell Intl Inc",  price = 38.77, change = 0.05, pctChange = 0.13, lastChange = "9/1 12:00am" },
                   new { company = "Intel Corporation",  price = 19.88, change = 0.31, pctChange = 1.58, lastChange = "9/1 12:00am" },
                   new { company = "International Business Machines",  price = 81.41, change = 0.44, pctChange = 0.54, lastChange = "9/1 12:00am" },
                   new { company = "Johnson & Johnson",  price = 64.72, change = 0.06, pctChange = 0.09, lastChange = "9/1 12:00am" },
                   new { company = "JP Morgan & Chase & Co",  price = 45.73, change = 0.07, pctChange = 0.15, lastChange = "9/1 12:00am" },
                   new { company = "McDonald\"s Corporation",  price = 36.76, change = 0.86, pctChange = 2.40, lastChange = "9/1 12:00am" },
                   new { company = "Merck & Co., Inc.",  price = 40.96, change = 0.41, pctChange = 1.01, lastChange = "9/1 12:00am" },
                   new { company = "Microsoft Corporation",  price = 25.84, change = 0.14, pctChange = 0.54, lastChange = "9/1 12:00am" },
                   new { company = "Pfizer Inc",  price = 27.96, change = 0.4, pctChange = 1.45, lastChange = "9/1 12:00am" },
                   new { company = "The Coca-Cola Company",  price = 45.07, change = 0.26, pctChange = 0.58, lastChange = "9/1 12:00am" },
                   new { company = "The Home Depot, Inc.",  price = 34.64, change = 0.35, pctChange = 1.02, lastChange = "9/1 12:00am" },
                   new { company = "The Procter & Gamble Company",  price = 61.91, change = 0.01, pctChange = 0.02, lastChange = "9/1 12:00am" },
                   new { company = "United Technologies Corporation",  price = 63.26, change = 0.55, pctChange = 0.88, lastChange = "9/1 12:00am" },
                   new { company = "Verizon Communications",  price = 35.57, change = 0.39, pctChange = 1.11, lastChange = "9/1 12:00am" },
                   new { company = "Wal-Mart Stores, Inc.",  price = 45.45, change = 0.73, pctChange = 1.63, lastChange = "9/1 12:00am" }
                };
            }
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Ext.NET v3 Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            
            <ext:GridPanel 
                ID="GridPanel1" 
                runat="server" 
                Width="600" 
                Height="350">
                <Store>
                    <ext:Store ID="Store1" runat="server">
                        <Model>
                            <ext:Model runat="server">
                                <Fields>
                                    <ext:ModelField Name="company" />
                                    <ext:ModelField Name="price" Type="Float" />
                                    <ext:ModelField Name="change" Type="Float" />
                                </Fields>
                            </ext:Model>
                        </Model>
                    </ext:Store>
                </Store>
                <ColumnModel runat="server">
                    <Columns>
                        <ext:Column runat="server" Text="Price" DataIndex="price" />
                        <ext:Column runat="server" Text="Change" DataIndex="change" />
                    </Columns>
                </ColumnModel>
                <Plugins>
                    <ext:GridFilters />
                </Plugins>
                <BottomBar>
                    <ext:Toolbar runat="server">
                        <Items>
                            <ext:ToolbarFill runat="server" />
                             <ext:Button runat="server" Text="Reconfigure">
                                 <DirectEvents>
                                    <Click OnEvent="Reconfigure" />
                                 </DirectEvents>
                            </ext:Button>
                        </Items>
                    </ext:Toolbar>
                </BottomBar>
            </ext:GridPanel>  
        </form>
    </body>
    </html>
  4. #4
    Reviewing my code, the problem was in grid.filters.Filters class.

    I solved with this way.


     <script type="text/javascript">
            Ext.define('Overrides.grid.filters.Filters', {
                override: 'Ext.grid.filters.Filters',
    
                onReconfigure: function (grid, store, columns, oldStore) {
                    var me = this;
    
                    me.sep = Ext.destroy(me.sep);
                    if (me.menuItems && me.menuItems[grid.id]) {
                        me.menuItems[grid.id].destroy();
                    }
    
                    me.callParent(arguments);
                }
            });
        </script>

Similar Threads

  1. Replies: 6
    Last Post: Aug 14, 2014, 4:45 PM
  2. Replies: 1
    Last Post: Mar 06, 2014, 4:21 AM
  3. [CLOSED] GridPanel reconfigure issue
    By snow_cap in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Dec 10, 2013, 7:58 PM
  4. Replies: 2
    Last Post: Oct 04, 2013, 11:39 AM
  5. [CLOSED] Add GridFilters after Gridpanel reconfigure MVC
    By RCM in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Aug 24, 2012, 4:12 PM

Tags for this Thread

Posting Permissions