[CLOSED] Ext.Net GridPanel Filters are lost after use Reconfigure Method

Page 1 of 3 123 LastLast
  1. #1

    [CLOSED] Ext.Net GridPanel Filters are lost after use Reconfigure Method

    Actualy I'm using Reconfigure() Method to reload ColumnModel and Store to a GridPanel. I used the Render() method before, but data didn't show after reload.

    After using Reconfigure() method, this removes the filters that were previously assigned in design. So I read on another forum that could add filters after call this method. Could you tell me why this doesn't show the filters if these are added after.

    private void ConfigureMDEGridPanel(IList<MetricsDataItem> items)
            {
    
                if (items == null || ListData== null)
                    return;
    
                var filterColl = new GridFilterCollection();
                var gridFilters = new GridFilters();
               
                var fieldsList = new List<RecordField>
                {
                    new RecordField("Id"),
                    new RecordField("StartedOn"){SortType=SortTypeMethod.AsDate,SortDir=SortDirection.DESC},
                    new RecordField("ShiftName"),
                    new RecordField("EndedOn"),
                    new RecordField("CreatedBy"),
                    new RecordField("RelatedIds"),
                    new RecordField("CreatedOn"),
                    new RecordField("ShiftCode")
                };
    
    
                var columnsList = new List<ColumnBase>{new Column {
                                                          ColumnID = "StartedOn",
                                                          Header = "Date",
                                                          DataIndex = "StartedOn",
                                                          Renderer = {Fn = "Ext.util.Format.dateRenderer('m/d/Y')"},
                                                          Align = Alignment.Center,
                                                          Width = 85}};
                if (ShowShiftColumn)
                    columnsList.Add(new Column
                    {
                        ColumnID = "ShiftName",
                        Header = "Shift",
                        DataIndex = "ShiftName",
                        Align = Alignment.Center,
                        Width = 120
                    });
    
                foreach (var objectName in ListData)
                {
                    fieldsList.Add(new RecordField(objectName .Replace(" ", "")));
    
                    columnsList.Add(new Column
                    {
                        ColumnID = objectName ,
                        Header = objectName ,
                        DataIndex = objectName .Replace(" ", ""),
                        Align = Alignment.Center,
                        Width = 140
                    });
    
                    filterColl.Add(new NumericFilter { DataIndex = objectName .Replace(" ", "") });
                }
    
                columnsList.Add(new Column
                {
                    ColumnID = "CreatedBy",
                    Header = "User",
                    DataIndex = "CreatedBy",
                    Align = Alignment.Center,
                    Width = 200
                });
    
                var commandColumn = new CommandColumn
                {
                    ColumnID = "Commands",
                    Align = Alignment.Center,
                    Width = 50
                };
    
                commandColumn.Commands.Add(new GridCommand
                {
                    CommandName = "Edit",
                    Text = "Edit",
                    IconCls = "icon-edit"
                });
    
                commandColumn.Commands.Add(new GridCommand
                {
                    CommandName = "Delete",
                    Text = "Delete",
                    IconCls = "icon-remove"
                });
    
                columnsList.Add(commandColumn);
    
                GridStore.RemoveFields();
    
                foreach (var recordField in fieldsList)
                    GridStore.AddField(recordField);
    
                GridPanel.ColumnModel.Columns.Clear();
                GridPanel.ColumnModel.Columns.AddRange(columnsList);
                GridPanel.ColumnModel.DefaultWidth = 300;
                GridPanel.AutoExpandColumn = "Commands";
                GridPanel.DataBind();
                
                var dateFilterStartedOn = new DateFilter();
                dateFilterStartedOn.DataIndex = "StartedOn";
                dateFilterStartedOn.DatePickerOptions.TodayText = "Now";
                filterColl.Add(dateFilterStartedOn);
    
                filterColl.Add(new StringFilter { DataIndex = "ShiftName"});
    
                var dateFilterEndedOn = new DateFilter();
                dateFilterEndedOn.DataIndex = "EndedOn";
                dateFilterEndedOn.DatePickerOptions.TodayText = "Now";
                filterColl.Add(dateFilterEndedOn);
    
                filterColl.Add(new StringFilter { DataIndex = "CreatedBy" });
    
                filterColl.Add(new StringFilter { DataIndex = "RelatedIds" });
                
                var dateFilterCreatedOn = new DateFilter();
                dateFilterCreatedOn.DataIndex = "CreatedOn";
                dateFilterCreatedOn.DatePickerOptions.TodayText = "Now";
                filterColl.Add(dateFilterCreatedOn);
    
                filterColl.Add(new StringFilter { DataIndex = "ShiftCode" });
    
    
                if (ExtNet.IsAjaxRequest)
                {
                    GridPanel.Reconfigure(GridStore.ClientID, GridPanel.ColumnModel);
                    GridPanel.RegisterColumnPlugins();
                    GridPanel.ColumnModel.RegisterCommandStyleRules();
    
                    gridFilters.ID = "GridPanelFilters";
                    gridFilters.Local = true;
                    gridFilters.Filters.AddRange(filterColl);
    
                    GridPanel.Plugins.Add(gridFilters);
                }
            }
    Last edited by Daniil; Jan 31, 2012 at 6:12 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Please clarify do you use Ext.NET v1.x, right?
  3. #3
    Hi

    We are currently using Ext.NET v1.2,

    Guillermo Calderon
    Development Team
  4. #4
    Moving to the 1.x Premium Help forum.


    Regarding the question.

    Please follow:
    http://forums.ext.net/showthread.php?12916
    http://forums.ext.net/showthread.php...ll=1#post66424
  5. #5
    This are examples files from a Web Application Test Solution and the and test data are still not displayed

    GCM
    Attached Thumbnails Click image for larger version. 

Name:	GridModel.png 
Views:	120 
Size:	23.9 KB 
ID:	3732  
    Attached Files
  6. #6
    I guess an empty grid is not related to losing the filters.

    Please post a sample right here wrapping in [CODE ] tags.
  7. #7
    What I want to show is that when I add the store, the columns and filters from code, the filters are removed from the emergent menu and also the data isn't show.

    Do you see the example that I post?

    GCM
  8. #8
    Here is the Code

    ASP CODE

    <%@ Page Title="Home Page" Language="C#" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <ext:Store ID="GridStore" runat="server" AutoLoad="true" />
    <ext:ResourceManager ID="ResourceManager1" runat="server" DirectEventUrl="default.aspx" />
    
    <ext:Panel ID="MDEMetricsPanel" runat="server" Border="false">
        <Content>
        <ext:Container ID="MDEMetricsContainer" runat="server" >
                <Items>
                    <ext:GridPanel ID="GridPanel" runat="server" AutoHeight="true" Layout="FitLayout" StoreID="GridStore"> 
                        <SelectionModel>
                            <ext:RowSelectionModel />
                        </SelectionModel>
                        <Plugins>
                            <ext:GridFilters runat="server" ID="GridPanelFilters" Local="true">
                                <Filters/>
                            </ext:GridFilters>
                        </Plugins>
                    </ext:GridPanel>
                </Items>
            </ext:Container>
        </Content>
    </ext:Panel>

    CODE BEHIND

    using System;
    using System.Collections.Generic;
    using System.Data;
    using Ext.Net;
    using DataView = System.Data.DataView;
    
    namespace WebApplication1
    {
        public partial class _Default : System.Web.UI.Page
        {
            public class testItem
            {
                public int Id { get; set; }
                public double Price  { get; set; }
                public string Company  { get; set; }
                public DateTime Date  { get; set; }
                public string Size  { get; set; }
                public bool Visible { get; set; }
            }
            
            public static List<testItem> Data
            {
                get
                {
                    var items = new List<testItem>
                                {
                                    new testItem
                                        {
                                            Id = 1,
                                            Price = 71.72,
                                            Company = "3m Co",
                                            Date = new DateTime(2007, 9, 1),
                                            Size = "large",
                                            Visible = true
                                        },
                                    new testItem
                                        {
                                            Id = 2,
                                            Price = 29.01,
                                            Company = "Aloca Inc",
                                            Date = new DateTime(2007, 08, 01),
                                            Size = "medium",
                                            Visible = false
                                        },
                                    new testItem
                                        {
                                            Id = 3,
                                            Price = 83.81,
                                            Company = "Altria Group Inc",
                                            Date = new DateTime(2007, 08, 03),
                                            Size = "large",
                                            Visible = false
                                        },
                                    new testItem
                                        {
                                            Id = 4,
                                            Price = 52.55,
                                            Company = "American Express Company",
                                            Date = new DateTime(2008, 01, 04),
                                            Size = "extra large",
                                            Visible = true
                                        },
                                    new testItem
                                        {
                                            Id = 5,
                                            Price = 64.13,
                                            Company = "American International Group Inc.",
                                            Date = new DateTime(2008, 03, 04),
                                            Size = "small",
                                            Visible = true
                                        },
                                    new testItem
                                        {
                                            Id = 6,
                                            Price = 31.61,
                                            Company = "AT&T Inc.",
                                            Date = new DateTime(2008, 02, 01),
                                            Size = "extra large",
                                            Visible = false
                                        },
                                    new testItem
                                        {
                                            Id = 7,
                                            Price = 75.43,
                                            Company = "Boeing Co.",
                                            Date = new DateTime(2008, 01, 01),
                                            Size = "large",
                                            Visible = true
                                        }                               
                                };
    
                    return items ;
                }
            }
    
            public DataTable DataEntryTable
            {
                get
                {
                    var dataTable = new DataTable("DataEntryTable");
    
                    dataTable.Columns.Add("Id");
                    dataTable.Columns.Add("Price");
                    dataTable.Columns.Add("Company");
                    dataTable.Columns.Add("Date");
                    dataTable.Columns.Add("Size");
                    dataTable.Columns.Add("Visible");
    
                    return dataTable;
                }
            }
    
            protected void Page_Load(object sender, EventArgs e)
            {
                SetGridItems(Data, DataEntryTable);
            }
    
            private void SetGridItems(IList<testItem> items, DataTable entriesDataTable)
            {
                var parsedItemsDataTable = GetGridItemsDataTable(items, entriesDataTable);
    
                ConfigureMDEGridPanel();
    
                var dataView = new DataView(parsedItemsDataTable);
    
                GridStore.DataSource = dataView;
                GridStore.DataBind();
            }
    
            private void ConfigureMDEGridPanel()
            {
                GridPanel.ColumnModel.Columns.Clear();
    
                var filterColl = new GridFilterCollection();
    
                var fieldsList = new List<RecordField>
                {
                    new RecordField("Id"),
                    new RecordField("Price"),
                    new RecordField("Company"),
                    new RecordField("Date"){SortType=SortTypeMethod.AsDate,SortDir=SortDirection.DESC},
                    new RecordField("Size"),
                    new RecordField("Visible")
                };
    
               GridStore.RemoveFields();
    
                foreach (var recordField in fieldsList)
                    GridStore.AddField(recordField);
    
                GridPanel.ColumnModel.Columns.Add(new Column
                {
                    ColumnID = "Id",
                    Header = "Id",
                    DataIndex = "Id",
                    Align = Alignment.Center,
                    Width = 100
                });
    
                GridPanel.ColumnModel.Columns.Add(new Column
                {
                    ColumnID = "Price",
                    Header = "Price",
                    DataIndex = "Price",
                    Align = Alignment.Center,
                    Width = 100
                });
    
                GridPanel.ColumnModel.Columns.Add(new Column
                {
                    ColumnID = "Company",
                    Header = "Company",
                    DataIndex = "Company",
                    Align = Alignment.Center,
                    Width = 100
                });
                
                GridPanel.ColumnModel.Columns.Add(new Column
                {
                    ColumnID = "Date",
                    Header = "Date",
                    DataIndex = "Date",
                    Renderer = { Fn = "Ext.util.Format.dateRenderer('m/d/Y')" },
                    Align = Alignment.Center,
                    Width = 85
                });
    
                GridPanel.ColumnModel.Columns.Add(new Column
                {
                    ColumnID = "Size",
                    Header = "Size",
                    DataIndex = "Size",
                    Align = Alignment.Center,
                    Width = 100
                });
    
                GridPanel.ColumnModel.Columns.Add(new Column
                {
                    ColumnID = "Visible",
                    Header = "Visible",
                    DataIndex = "Visible",
                    Align = Alignment.Center,
                    Width = 100
                }); 
    
                GridPanel.ColumnModel.DefaultWidth = 300;
                GridStore.DataBind();
    
                var dateFilterStartedOn = new DateFilter();
                dateFilterStartedOn.DataIndex = "Date";
                dateFilterStartedOn.DatePickerOptions.TodayText = "Now";
                filterColl.Add(dateFilterStartedOn);
    
                filterColl.Add(new NumericFilter { DataIndex = "Price" });
    
                filterColl.Add(new StringFilter { DataIndex = "Company" });
    
                filterColl.Add(new StringFilter { DataIndex = "Size" });
    
                if (ExtNet.IsAjaxRequest)
                {
                    GridPanelFilters.Filters.AddRange(filterColl);
                    GridPanel.RegisterColumnPlugins();
                    GridPanel.ColumnModel.RegisterCommandStyleRules();
                }
            }
    
            private static DataTable GetGridItemsDataTable(IList<testItem> items, DataTable entriesDataTable)
            {
                foreach (var o in items)
                {
                    var row = entriesDataTable.NewRow();
    
                    row["Id"] = o.Id;
                    row["Price"] = o.Price;
                    row["Company"] = o.Company;
                    row["Date"] = o.Date;
                    row["Size"] = o.Size;
                    row["Visible"] = o.Visible;
                    
                    entriesDataTable.Rows.Add(row);
                }
    
                return entriesDataTable;
            }
    
        }
    }
  9. #9
    I can't see where you define a Reader for the Store.

    Please define:
    <ext:Store ID="GridStore" runat="server">
        <Reader>
            <ext:JsonReader />
        </Reader>
    </ext:Store>
    Also please remove:
    GridStore.RemoveFields();
    and replace
    GridStore.AddField(recordField);
    with
    GridStore.Reader[0].Fields.Add(recordField);
    Please use the AddField and RemoveFields during DirectEvent only.

    Regarding to:
    I used the Render() method before, but data didn't show after reload.
    Please clarify did you look at the example I've referred? This one:
    http://forums.ext.net/showthread.php...ll=1#post66424

    It works fine with .Render() calling.
  10. #10
    I found this link to add the Grid Filters after Reconfigure Method

    http://forums.ext.net/showthread.php...ll=1#post54217

    But this line is given me an error and doesn't work properly.

    GridPanel1.filters.destroy();
    Because filters are never added to the grid.
Page 1 of 3 123 LastLast

Similar Threads

  1. [CLOSED] GridPanel created in Javascript. Reconfigure.
    By supera in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: Apr 27, 2012, 2:01 PM
  2. Replies: 3
    Last Post: Jan 12, 2012, 3:26 PM
  3. [CLOSED] Hidden Change and Grid Filters are not working after Grid Reconfigure
    By speedstepmem3 in forum 1.x Legacy Premium Help
    Replies: 15
    Last Post: Oct 16, 2011, 1:12 PM
  4. [CLOSED] Problem when calling reconfigure for gridpanel using borderlayout
    By Pablo_Azevedo in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Aug 05, 2011, 1:26 PM
  5. Replies: 2
    Last Post: Mar 30, 2010, 10:25 AM

Tags for this Thread

Posting Permissions