[CLOSED] How to provide filter option for CheckboxSelectionModel in GridPanel to filter Selected/Unselected rows

  1. #1

    [CLOSED] How to provide filter option for CheckboxSelectionModel in GridPanel to filter Selected/Unselected rows

    Team,

    I am to challenges in GridPanel filters.

    1. I have a GridPanel with CheckboxSelectionModel.

    I want to provide the filter option on this CheckboxSelectionModel column which helps me to filter the rows which are Selected/Unselected.

    Please refer the attached screenshot. Click image for larger version. 

Name:	FilterForCheckBoxSelectionModelColumn.JPG 
Views:	113 
Size:	52.7 KB 
ID:	5747

    2. Giving ALL and (Blank) for NumericFilter and ListFilter.
    ALL -> to select all the data in ListFilter
    (Blank) -> to filter only the rows which has null/blank values in the filtered column.
    Last edited by Daniil; Mar 19, 2013 at 4:25 AM. Reason: [CLOSED]
  2. #2
    Hello!

    Quote Originally Posted by Tarun Chand View Post
    Team,

    I am to challenges in GridPanel filters.

    1. I have a GridPanel with CheckboxSelectionModel.

    I want to provide the filter option on this CheckboxSelectionModel column which helps me to filter the rows which are Selected/Unselected.

    Please refer the attached screenshot. Click image for larger version. 

Name:	FilterForCheckBoxSelectionModelColumn.JPG 
Views:	113 
Size:	52.7 KB 
ID:	5747
    How do you want to display this filter options? Add button in Grid's toolbar or add menu to the header: Click image for larger version. 

Name:	1.JPG 
Views:	60 
Size:	13.6 KB 
ID:	5748

    Quote Originally Posted by Tarun Chand View Post
    2. Giving ALL and (Blank) for NumericFilter and ListFilter.
    ALL -> to select all the data in ListFilter
    (Blank) -> to filter only the rows which has null/blank values in the filtered column.
    You can implement this using http://docs.sencha.com/ext-js/4-1/#!...ethod-filterBy and by extending http://docs.sencha.com/ext-js/4-1/#!....NumericFilter and http://docs.sencha.com/ext-js/4-1/#!...ter.ListFilter
  3. #3
    Quote Originally Posted by Baidaly View Post
    Hello!


    How do you want to display this filter options? Add button in Grid's toolbar or add menu to the header: Click image for larger version. 

Name:	1.JPG 
Views:	60 
Size:	13.6 KB 
ID:	5748



    You can implement this using http://docs.sencha.com/ext-js/4-1/#!...ethod-filterBy and by extending http://docs.sencha.com/ext-js/4-1/#!....NumericFilter and http://docs.sencha.com/ext-js/4-1/#!...ter.ListFilter

    Baidaly,

    Thanks for your response,

    1. For the first problem,

    I want very similar to the screenshot which you have attached, I want the filter at the CheckBoxSelection column header level.

    2. For the the second problem.
    I went through the links you have provided, it would have been great if i get a link/code for a sample.
  4. #4
    Hello,

    Unfortunately, we have no such an example.

    But we can help you to start.

    I would start from enabling a menu for a column with checkboxes. Probably, overriding the getHeaderConfig function is the simplest way.

    Secondly, I would go this way - remove all default items and add some custom one (ones) to apply filtering.

    I feel that trying to get it working with GridFilters may be more complicated.

    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();
            }
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    
        <script>
            var myGetHeaderConfig = function() {
                var me = this,
                    showCheck = me.showHeaderCheckbox !== false;
    
                return {
                    isCheckerHd: showCheck,
                    text : '*',
                    width: me.headerWidth,
                    sortable: false,
                    draggable: false,
                    resizable: false,
                    hideable: false,
                    //menuDisabled: true,
                    menuDisabled: false,
                    dataIndex: '',
                    cls: showCheck ? Ext.baseCSSPrefix + 'column-header-checkbox ' : '',
                    renderer: Ext.Function.bind(me.renderer, me),
                    editRenderer: me.editRenderer || me.renderEmpty,
                    locked: me.hasLockedHeader()
                };
            };
        </script>
    </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" />
                                    <ext:ModelField Name="test3" />
                                </Fields>
                            </ext:Model>
                        </Model>
                    </ext:Store>
                </Store>
                <ColumnModel runat="server">
                    <Columns>
                        <ext:Column runat="server" Text="Test1" DataIndex="test1" />
                        <ext:Column runat="server" Text="Test2" DataIndex="test2" />
                        <ext:Column runat="server" Text="Test3" DataIndex="test3" />
                    </Columns>
                </ColumnModel>
                <SelectionModel>
                    <ext:CheckboxSelectionModel runat="server">
                        <CustomConfig>
                            <ext:ConfigItem Name="getHeaderConfig" Value="myGetHeaderConfig" Mode="Raw" />
                        </CustomConfig>
                    </ext:CheckboxSelectionModel>
                </SelectionModel>
            </ext:GridPanel>
        </form>
    </body>
    </html>
    Last edited by Daniil; Mar 12, 2013 at 7:52 AM.
  5. #5
    Quote Originally Posted by Daniil View Post
    Hello,

    Unfortunately, we have no such an example.

    But we can help you to start.

    I would start from enabling a menu for a column with checkboxes. Probably, overriding the getHeaderConfig function is the simplest way.

    Secondly, I would go this way - remove all default items and add some custom one (ones) to apply filtering.

    I feel that trying to get it working with GridFilters may be more complicated.
    Daniil,

    Thank you for your support and suggestion.
    I tried the sample which you have given in the previous post, but I did not understand, how to add the items to the menu for fitering like (Selected/Unselected to that menu).

    I appreciate If you can help me in understanding the approach you have explained.
  6. #6
    I think Daniil meant some like this:

    <%@ 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();
            }
        }
    </script>
     
    <!DOCTYPE html>
     
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
     
        <script>
            var myGetHeaderConfig = function() {
                var me = this,
                    showCheck = me.showHeaderCheckbox !== false;
                
                this.view.headerCt.on('menucreate', function(menu) {
                    menu.menu.add({
                        text: 'Filter selected',
                        menu: Ext.create('Ext.menu.Menu', {
                            items: [{
                                text: 'Selected',
                                handler: function() {
                                    var selected = this.view.getSelectionModel().getSelection(); 
                                    this.view.getStore().filterBy(function(record) {
                                        return this.indexOf(record) != -1;
                                    }, selected);
                                },
                                view: me.view
                            }, {
                                text: 'Not selected',
                                handler: function() {
                                    var selected = this.view.getSelectionModel().getSelection(); 
                                    this.view.getStore().filterBy(function(record) {
                                        return this.indexOf(record) == -1;
                                    }, selected);
                                },
                                view: me.view
                            }, {
                                text: 'Clear',
                                handler: function() {
                                    this.view.getStore().clearFilter();
                                },
                                view: me.view
                            }]
                        })
                    });
                }, me);
                
                return {
                    isCheckerHd: showCheck,
                    text : '&#160;',
                    width: me.headerWidth,
                    sortable: false,
                    draggable: false,
                    resizable: false,
                    hideable: false,
                    menuDisabled: false,
                    dataIndex: '',
                    dataIndex: 'test',
                    cls: showCheck ? Ext.baseCSSPrefix + 'column-header-checkbox ' : '',
                    renderer: Ext.Function.bind(me.renderer, me),
                    editRenderer: me.editRenderer || me.renderEmpty,
                    locked: me.hasLockedHeader()
                };
            };
        </script>
    </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" />
                                    <ext:ModelField Name="test3" />
                                </Fields>
                            </ext:Model>
                        </Model>
                    </ext:Store>
                </Store>
                <ColumnModel runat="server">
                    <Columns>
                        <ext:Column runat="server" Text="Test1" DataIndex="test1" />
                        <ext:Column runat="server" Text="Test2" DataIndex="test2" />
                        <ext:Column runat="server" Text="Test3" DataIndex="test3" />
                    </Columns>
                </ColumnModel>
                <SelectionModel>
                    <ext:CheckboxSelectionModel runat="server">
                        <CustomConfig>
                            <ext:ConfigItem Name="getHeaderConfig" Value="myGetHeaderConfig" Mode="Raw" />
                        </CustomConfig>
                    </ext:CheckboxSelectionModel>
                </SelectionModel>
            </ext:GridPanel>
        </form>
    </body>
    </html>
  7. #7
    Quote Originally Posted by Baidaly View Post
    I think Daniil meant some like this:

    Thanks you Baidaly and Daniil. It works, but It fails to to consider the filters applied on the other columns.

    Example:
    - Grid contains 100 rows and after a filter is applied on some other column it leaves behind only 10 rows in the grid.
    - Then when we apply filter on CheckboxSelectionModel column, say I want to see the Not Selected Columns, it will also fetch not selected rows from the initial 100 rows, it won't consider the filter applied on the other columns.

    Baidaly,

    Thanks for your response and the snippet of code, I request you to guide me how can I retain the filters applied on other columns when we use filter on CheckboxSelectionModel column.


    Cheers...
  8. #8
    I didn't think about it. I think it is possible to get it working.

    Then I have another suggestion which should be easier to implement.

    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();
            }
        }
    </script>
     
    <!DOCTYPE html>
     
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
     
        <script>
            var myGetHeaderConfig = function() {
                var me = this,
                    showCheck = me.showHeaderCheckbox !== false;
     
                return {
                    isCheckerHd: showCheck,
                    text : '&#160;',
                    width: me.headerWidth,
                    sortable: false,
                    draggable: false,
                    resizable: false,
                    hideable: false,
                    menuDisabled: false, // was true
                    dataIndex: 'selected', // was ''
                    cls: showCheck ? Ext.baseCSSPrefix + 'column-header-checkbox ' : '',
                    renderer: Ext.Function.bind(me.renderer, me),
                    editRenderer: me.editRenderer || me.renderEmpty,
                    locked: me.hasLockedHeader()
                };
            };
        </script>
    </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" />
                                    <ext:ModelField Name="test3" />
                                    <ext:ModelField Name="selected" Type="Boolean" />
                                </Fields>
                            </ext:Model>
                        </Model>
                    </ext:Store>
                </Store>
                <ColumnModel runat="server">
                    <Columns>
                        <ext:Column runat="server" Text="Test1" DataIndex="test1" />
                        <ext:Column runat="server" Text="Test2" DataIndex="test2" />
                        <ext:Column runat="server" Text="Test3" DataIndex="test3" />
                    </Columns>
                </ColumnModel>
                <SelectionModel>
                    <ext:CheckboxSelectionModel runat="server" PruneRemoved="false">
                        <CustomConfig>
                            <ext:ConfigItem Name="getHeaderConfig" Value="myGetHeaderConfig" Mode="Raw" />
                        </CustomConfig>
                        <Listeners>
                            <Select Handler="record.data.selected = true;" />
                            <Deselect Handler="record.data.selected = false;" />
                        </Listeners>
                    </ext:CheckboxSelectionModel>
                </SelectionModel>
                <Features>
                    <ext:GridFilters runat="server" Local="true">
                        <Filters>
                            <ext:BooleanFilter DataIndex="selected" YesText="Selected" NoText="Not selected" />
                            <ext:StringFilter DataIndex="test1" />
                        </Filters>
                    </ext:GridFilters>
                </Features>
            </ext:GridPanel>
        </form>
    </body>
    </html>

Similar Threads

  1. Replies: 10
    Last Post: Mar 05, 2013, 6:05 AM
  2. Replies: 2
    Last Post: May 01, 2012, 4:57 PM
  3. Filter Grid Panel by Selected Rows
    By JIGSAW in forum 1.x Help
    Replies: 2
    Last Post: Feb 25, 2011, 12:46 PM
  4. Replies: 2
    Last Post: Dec 02, 2009, 12:08 PM
  5. [CLOSED] Storing the unselected filter in the grid panel in my database....
    By speedstepmem2 in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Dec 09, 2008, 12:31 AM

Tags for this Thread

Posting Permissions