[FIXED] [#30] [2.x] Dynamically Freeze Grid Column

Page 2 of 3 FirstFirst 123 LastLast
  1. #11
    Hi,

    I will do into in the before render of the ViewPort.

    Do I need to set the filters for both normalgrid and lockedgrid as original grid no longer has the filters property.

    App.gridPanelGridView.filters
    - Filter no longer exists

    App.gridPanelGridView.normalGrid.filters
    
    App.gridPanelGridView.LockedGrid.filters

    Is there any other pieces i need to pay attention to.
  2. #12
    Hi,

    I have the gridpanel now working with the locking. However the filters only works for the locked columns. If I apply a filter to a column that is not locked, the filter is not being sent to the server. any ideas why this behavior.
  3. #13
    Hi,

    Please see my sample below. I can't seem to get the filter to work consisitently between the locked and unlocked columns. Please offer some assistance.




    View

    <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!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 id="Head1" runat="server">
        <title></title>
        <meta content="NO-CACHE" http-equiv="CACHE-CONTROL" />
        <%-- Override the default label seperator and set to ""--%>
        <ext:ResourcePlaceHolder runat="server" Mode="ScriptFiles" />
        <script type="text/javascript">
            Ext.Component.prototype.labelSeparator = "";
        </script>
        <script src="/Scripts/GridView.js" type="text/javascript"></script>
        <style type="text/css">
            .Header
            {
                font: 12px helvetica,arial,sans-serif;
            }
            .list-over
            {
                background-color: white;
            }
            
            .my-listview .x-list-body dt
            {
                white-space: normal;
                cursor: arrow;
            }
        </style>
        <script type="text/javascript">
            var formatDate = function (v) {
                return value.format(Common.GetJSDateFormat());
            };
        </script>
    </head>
    <body>
        <ext:ResourceManager runat="server">
            <Listeners>
            </Listeners>
        </ext:ResourceManager>
        <ext:Viewport ID="viewportResultView" runat="server" Layout="FitLayout" IDMode="Static">
            <Items>
                <ext:GridPanel ID="gridPanelGridView" EnableLocking ="true"  runat="server"  Region="Center">
                    <TopBar>
                        <ext:Toolbar runat ="server">
                            <Items>
                                <ext:Button runat ="server" Text ="Load With Error">
                                    <Listeners>
                                        <Click Handler="GridView.LoadAndThrowError();" />
                                    </Listeners>
                                </ext:Button>
                            </Items>
                        </ext:Toolbar>
                    </TopBar>
                    <SelectionModel>
                        <ext:RowSelectionModel runat="server" PruneRemoved="false" Mode="Multi" />
                    </SelectionModel>
                    <ColumnModel>
                        <Columns>
                            <ext:RowNumbererColumn runat="server" Width="50" Sortable="false" />
                        </Columns>
                        <Listeners>
                        </Listeners>
                    </ColumnModel>
                    <Store>
                        <ext:Store runat="server" Buffered="true" PageSize="5">
                            <Model>
                                <ext:Model runat="server">
                                    <Fields>
                                        <ext:ModelField Name="dummy" />
                                    </Fields>
                                </ext:Model>
                            </Model>
                        </ext:Store>
                    </Store>
                    <Features>
                        <ext:GridFilters runat="server" ID="gridFiltersGridView" Local="false" MenuFilterText="temp"
                            ParamPrefix="filter" AutoDataBind="true">
                            <Filters>
                                <ext:BooleanFilter />
                            </Filters>
                            <Listeners>
                            </Listeners>
                        </ext:GridFilters>
                    </Features>
                    <View>
                        <ext:GridView LoadingText="" LoadMask="false">
                            <Listeners>
                                <BeforeRender Handler="GridView.InitializeView();" />
                            </Listeners>
                        </ext:GridView>
                    </View>
                    <Listeners>
                        <CellDblClick Fn="" />
                        <ContainerContextMenu Fn="" />
                        
                    </Listeners>
                </ext:GridPanel>
            </Items>
            <Listeners>
                <Render />
            </Listeners>
        </ext:Viewport>
    </body>
    </html>


    Controller


     public class GridController : Controller
        {
            //
            // GET: /Grid/
    
            public ActionResult Index()
            {
                return View();
            }
    
    
            public StoreResult GetData( string filter, Boolean throwerror , int Start = 0, int PageSize =1, int PageIndex = 1)
            {
              
    
                StoreResult response = new StoreResult();
    
                List<User> data = new List<User>();
    
                Random randow = new Random();
                DateTime now = DateTime.Now;
    
                for (int i = Start + 1; i <= Start + PageSize; i++)
                {
                    User user = new User()
                    {
                        Firstname = "User " + i,
                        Lastname = "User Last " + i,
                        Age = i + 23
                    };
    
                    data.Add(user);
                }
    
                response.Data = data;
                response.Total = 3000;
    
                return response;
            }
    
        }
    
        public class User
        {
            public String Firstname { get; set; }
    
            public String Lastname { get; set; }
    
            public int Age { get; set; }
        }

    JavaScript


    Ext.override(Ext.grid.Panel, {
        normalCfgCopy: ['invalidateScrollerOnRefresh', 'verticalScroller', 'verticalScrollDock', 'verticalScrollerType', 'scroll', 'features'],
        lockedCfgCopy: ['invalidateScrollerOnRefresh', 'features']
    });
    
    
    Ext.define('Product', {
        extend: 'Ext.data.Model',
        fields: [{
            name: 'id',
            type: 'int'
        }, {
            name: 'company'
        }, {
            name: 'price',
            type: 'float'
        }, {
            name: 'date',
            type: 'date',
            dateFormat: 'Y-m-d'
        }, {
            name: 'visible',
            type: 'boolean'
        }, {
            name: 'size'
        }]
    });
    
    
    
    GridView = {
    
        InitializeView: function () {
    
            GridView.ReconfigureGrid();
        },
    
        CheckBoxHeaderClicked: function (e, t) {
            if (t && t.type === "checkbox" && t.id === "gridview-header-checkbox-columnWorkItemSelections") {
                var dataIndex = t.getAttribute('dataIndex');
                var grid = App.gridPanelGridView;
                grid.store.each(function (record) {
                    record.data[dataIndex] = t.checked;
                });
                grid.store.commitChanges();
                grid.view.refresh();
            }
        },
    
    
    
        ReconfigureGrid: function () {
            var columns = [
            {
                Xtype: "checkcolumn",
                editable: true,
                menuDisabled: true,
                dataIndex: "columnWorkItemSelections",
                onElClick: GridView.CheckBoxHeaderClicked,
                renderTpl: "<div id=\"{id}-titleEl\" {tipMarkup}class=\"x-column-header-inner gridview-header-container\"> <span id=\"{id}-textEl\" class=\"x-column-header-text\"><input id=\"gridview-header-checkbox-{id}\" type=\"checkbox\" dataIndex =\"columnWorkItemSelections\" class=\"gridview-header-checkbox\"></input>{text} </span> <tpl if=\"!menuDisabled\"> <div id=\"{id}-triggerEl\" class=\"x-column-header-trigger\"></div> </tpl> </div>"
            }];
    
            columns.push({ Xtype: "gridcolumn", text: 'First Name', dataIndex: 'Firstname', sourceIndex: "Firstname", locked: true, renderer: "", resizable: true, editable: false, isIcon: false, datatype: "string", hidden: false, width: 100, hasCheckBoxColumn: false });
            columns.push({ Xtype: "gridcolumn", text: 'Last Name', dataIndex: 'Lastname', sourceIndex: "Lastname", locked: true, renderer: "", resizable: true, editable: false, isIcon: false, datatype: "string", hidden: false, width: 100, hasCheckBoxColumn: false });
            columns.push({ Xtype: "gridcolumn", text: 'Age', dataIndex: 'Age', sourceIndex: "Age", locked: true, renderer: "", resizable: true, editable: false, isIcon: false, datatype: "string", hidden: false, width: 100, hasCheckBoxColumn: false });
    
    
            var cols = new Array();
            for (var index = 0; index < columns.length; index++) {
    
                cols.push(columns[index]);
            }
    
    
            var fields = [{ type: 'boolean', name: 'columnWorkItemSelections' }, { name: 'Firstname', type: 'string' }, { name: 'Lastname', type: 'string' }, { name: 'Age', type: 'int'}];
    
            var grid = App.gridPanelGridView;
    
            var store = GridView.CreateStore(fields);
    
    
            grid.reconfigureLockable(store, columns);
    
            GridView.SetGridFilters(columns, fields, store);
    
            store.loadPage(1);
    
        },
    
    
    
        CreateStore: function (fields) {
    
            return Ext.create('Ext.data.JsonStore', {
                remoteSort: true,
                remoteFilter: true,
                buffered: true,
                fields: fields,
                autoLoad: false,
                pageSize: 1000,
                showWarningOnFailure: false,
                proxy: {
                    type: "ajax",
                    url: "/Grid/GetData",
                    reader: {
                        root: "data",
                        type: "json",
                        totalProperty: 'total',
                        messageProperty: "message"
                    },
                    extraParams: {
                        ResultSetId: 1,
                        WorkflowStateId: 1,
                        TimePeriodId: 1,
                        RiskId: 1,
                        WorkitemPropertyId: 1,
                        WorkItemTypeId: 1,
                        TotalRecords: 1,
                        ResultSetTableName: 'namwe',
                        ResultSetLinkTableName: 'name'
                    },
                    groupParam: "Group",
                    limitParam: "PageSize",
                    pageParam: "PageIndex",
                    directionParam: "SortDirection",
                    sortParam: "Sort",
                    startParam: "Start",
                    listeners: {
                        exception: { fn: function (el, response, operation, eOpts) {
    
                            alert(operation.getError());
    
                        }
                        }//end exception
                    }
                },
                listeners: {
                    beforeload: { fn: function (store, operation, eOpts) {
                        var throwerror = false;
    
                        if (operation.throwerror) {
                            throwerror = operation.throwerror;
                        }
    
                        //Apply additional filter params
                        Ext.apply(store.getProxy().extraParams, {
                            throwerror: throwerror
                        });
    
    
                    }
                    },
                    load: { fn: function (store, operation, eOpts) {
    
    
                        //parent.Common.UnMask();
                    }
                    },
    
                    exception: { fn: function (el, response, operation, eOpts) {
    
                        alert(operation.getError());
    
                    }
                    }//end exception
                }
            });
        },
    
        SetGridFilters: function (columns, fields, store) {
    
            App.gridPanelGridView.lockedGrid.filters.clearFilters();
            App.gridPanelGridView.normalGrid.filters.clearFilters();
            for (var i = 0; i < columns.length; i++) {
                for (var j = 0; j < fields.length; j++) {
                    if (columns[i].dataIndex == fields[j].name) {
                        App.gridPanelGridView.normalGrid.filters.addFilter({ dataIndex: columns[i].dataIndex, type: fields[j].type });
                        App.gridPanelGridView.lockedGrid.filters.addFilter({ dataIndex: columns[i].dataIndex, type: fields[j].type });
                        break;
                    }
                }
            }
    
            App.gridPanelGridView.lockedGrid.bindStore(store);
            App.gridFiltersGridView.bindStore(store);
        },
    
        LoadAndThrowError: function () {
    
            App.gridPanelGridView.store.loadPage(1, { throwerror: true });
        },
    
    
    
        CreateGrid: function (columns, fields) {
    
            var store = Ext.create('Ext.data.JsonStore', {
                // store configs
                autoDestroy: true,
                remoteSort: true,
                remoteFilter: true,
                autoLoad: false,
                buffered: true,
                fields: fields,
                proxy: {
                    type: 'ajax',
                    url: "/Grid/GetData",
                    reader: {
                        type: 'json',
                        root: 'data',
                        idProperty: 'id',
                        totalProperty: 'total'
                    }
                },
                groupParam: "Group",
                limitParam: "PageSize",
                pageParam: "PageIndex",
                directionParam: "SortDirection",
                sortParam: "Sort",
                startParam: "Start",
                remoteSort: false,
                sorters: [{
                    property: 'Age',
                    direction: 'ASC'
                }],
                pageSize: 1000
            });
    
    
    
    
            var grid = Ext.create('Ext.grid.Panel', {
                border: false,
                store: store,
                columns: columns,
                loadMask: true
    
            });
    
    
    
            var win = Ext.create('Ext.Window', {
                title: 'Grid Filters Example',
                height: 400,
                width: 700,
                layout: 'fit',
                items: grid
            }).show();
    
            store.load();
    
    
    
        }
    
    
    }
    Last edited by Daniil; Oct 03, 2012 at 8:20 PM. Reason: Added CLOSED tag
  4. #14
    Hi ,

    I was just checking to see if you have any idea of the issues I am having above. I have been going at it for while but with no success. please offer any idea you may have.
  5. #15
    When I run the sample I am getting this JavaScript error:
    TypeError: lockedView.el is undefined
    Is this the problem? Or are you able to launch your sample?

    Also please clarify what is this code for?
    Ext.override(Ext.grid.Panel, {
        normalCfgCopy: ['invalidateScrollerOnRefresh', 'verticalScroller', 'verticalScrollDock', 'verticalScrollerType', 'scroll', 'features'],
        lockedCfgCopy: ['invalidateScrollerOnRefresh', 'features']
    });
  6. #16
    Hi,

    The error gets thrown when I use the

    <BeforeRender Handler="GridView.InitializeView();" />
    instead of

     <ViewReady Handler="GridView.InitializeView();" />
    Please change to get the sample runnning.


    Also please clarify what is this code for?
    1
    2
    3
    4
    Ext.override(Ext.grid.Panel, {
        normalCfgCopy: ['invalidateScrollerOnRefresh', 'verticalScroller', 'verticalScrollDock', 'verticalScrollerType', 'scroll', 'features'],
        lockedCfgCopy: ['invalidateScrollerOnRefresh', 'features']
    });
    I got the above code from the sencha forum as there was a known issue with the locking grid not handling features properly. I am not sure if it is required with the version of extjs built with the latest Ext.NET files.

    but if you change the above from BeforeRender to ViewReady the sample works fine and you will be able to see the filtering issue.

    thanks
  7. #17
    Quote Originally Posted by RCM View Post
    Ext.override(Ext.grid.Panel, {
        normalCfgCopy: ['invalidateScrollerOnRefresh', 'verticalScroller',  'verticalScrollDock', 'verticalScrollerType', 'scroll', 'features'],
        lockedCfgCopy: ['invalidateScrollerOnRefresh', 'features']
    });
    I got the above code from the sencha forum as there was a known issue with the locking grid not handling features properly. I am not sure if it is required with the version of extjs built with the latest Ext.NET files.
    Could you post that Sencha forum, please?

    Quote Originally Posted by RCM View Post
    but if you change the above from BeforeRender to ViewReady the sample works fine and you will be able to see the filtering issue.
    Ok, I was able to run the sample.

    Regarding this.

    Quote Originally Posted by RCM View Post
    I have the gridpanel now working with the locking. However the filters only works for the locked columns. If I apply a filter to a column that is not locked, the filter is not being sent to the server. any ideas why this behavior.
    I have found a bug report on this issue.
    http://www.sencha.com/forum/showthread.php?237419

    I made an update in this thread.
  8. #18
    Hi Danill,

    Sorry I can't find the thread on sencha. Never bookmarked the thread. but here is another link of another forum.

    http://stackoverflow.com/questions/1...ns-and-summary
  9. #19
    Thank you. I think it is a bug and reported it to Sencha.
    http://www.sencha.com/forum/showthread.php?244968
  10. #20
    Sencha opened a bug ticket. We will monitor.
Page 2 of 3 FirstFirst 123 LastLast

Similar Threads

  1. How to Dynamically add Listener to grid column?
    By jbarbeau in forum 2.x Help
    Replies: 5
    Last Post: Aug 25, 2014, 11:03 PM
  2. Dynamically Freeze Grid Column
    By RCM in forum 2.x Help
    Replies: 0
    Last Post: Oct 02, 2012, 3:07 AM
  3. Replies: 5
    Last Post: Sep 03, 2012, 1:38 PM
  4. Grid Header Freeze
    By jordnlvr in forum 1.x Help
    Replies: 1
    Last Post: Mar 27, 2010, 3:52 AM
  5. Freeze (Lock) Columns feature in Grid Panel.
    By kunal_icreon in forum 1.x Help
    Replies: 7
    Last Post: Feb 22, 2010, 3:52 AM

Posting Permissions