[CLOSED] Grid FilterHeader default type search

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    [CLOSED] Grid FilterHeader default type search

    Hi, when insert a FilterHeader plugin in a grid:

     <ext:GridPanel ID="GridPanelClienti" runat="server" StoreID="StoreCliAge" Cls="my-grid" >
                                    <ColumnModel>
                                        <Columns>
    
                                            <ext:Column runat="server" DataIndex="CliForCod" Text="Codice" Width="70" />
                                            <ext:Column runat="server" DataIndex="CliForRagSoc" Text="Cliente" Width="250" Wrap="True">
                                                <Renderer Fn="sospesi" />                                                                           
                                            </ext:Column>
                                            <ext:Column runat="server" DataIndex="ComCom" Text="Comune" Width="120" />
                                            <ext:Column runat="server" DataIndex="ProSig" Text="Prov." Width="40" />
                                            <ext:DateColumn ID="DataOrdine" runat="server" Align="Center" DataIndex="data" Text="Ult.Ord." Format="dd/MM/yyyy" Width="90" />
                                            <ext:Column runat="server" DataIndex="AgeDes" Text="Agente" Width="100" />
                                        </Columns>
                                    </ColumnModel>
     <Plugins>
                                        <ext:FilterHeader ID="FilterHeaderClienti" runat="server" OnCreateFilterableField="FilterHeaderClienti_CreateFilterableField" />
    </Plugins>
    </GridPanel


    the search by default is "Starts with"

    it's possible set the default to "Contains" ?

    I use this sample: https://examples2.ext.net/#/GridPane...ader/Overview/ and the column Company is by default "Starts with"

    Thank
    Aurelio
    Last edited by Daniil; Oct 28, 2013 at 3:46 PM. Reason: [CLOSED]
  2. #2
    For "Contains" logic you need to use '*' prefix, like
    "*group"
    Vladimir Shcheglov
    Sr. Developer
  3. #3
    Hi Vladimir...
    yes i read the prefix for search in the filter (+,*, ecc..)

    but il possibile set the default to 'Contains' ?
    without the user having to use the prefix ?

    it's possible use the Listener BeforeFilter to concatenate the '*' before the value and execute the filter ?

    <ext:FilterHeader ID="FilterHeaderClienti" runat="server" OnCreateFilterableField="FilterHeaderClienti_CreateFilterableField" >
                                           <Listeners>
                                               <BeforeFilter Fn="...." />
                                           </Listeners>                                       
                                        </ext:FilterHeader>
    I can not understand how I can concatenate '*' before the value and run the filter..

    Thanks
    Aurelio
  4. #4
    Please use the following override
    Ext.net.FilterHeader.behaviour.string[0].match = function (recordValue, matchValue) {
                return (Ext.net.FilterHeader.behaviour.getStrValue(recordValue) || "").indexOf(matchValue) > -1; 
            };
    
    
            Ext.net.FilterHeader.behaviour.string[0].serialize = function (value) {
                return {
                    type : "string",
                    op: "*",
                    value : value
                };
            };
    Vladimir Shcheglov
    Sr. Developer
  5. #5
    Hi. Vladimir

    Yeah it's work great..

    but i have a question: this override all columns to default 'Contains', it's possible set only a specific column to 'Contains' ?

    I test this code:

    function getCompanyValue(plugin) {
              
                if ((plugin.fields[1].value).substring(0, 1) != '*' && (plugin.fields[1].value).length > 1) {
                    plugin.fields[1].setValue("*" + plugin.fields[1].value);
                }
                            
            }
    It's work, but the question is: it's possible use the column name e not a number for the fields.. (plugin.fields[columnName]) ?

    Many Thanks

    Aurelio
  6. #6
    Please see the following sample
    <%@ 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)
            {
                this.Store1.DataSource = FiltersTestData.Data;
                this.Store1.DataBind();
            }
        }
    
    
        protected Field OnCreateFilterableField(object sender, ColumnBase column, Field defaultField)
        {
            if(column.DataIndex == "Company")
            {
                defaultField.CustomConfig.Add(new ConfigItem("getValue", "getCompanyValue", ParameterMode.Raw));
            }
            
            return defaultField;
        }
    </script>
    
    
    <!DOCTYPE html>
        
    <html>
    <head runat="server">
        <title></title>
    
    
        <script>
            function getCompanyValue() {
                var value = this.getRawValue();
                if (value && value[0] !== "*" && !Ext.net.FilterHeader.behaviour.getBehaviour("string", value)) {
                    return "*" + value;
                }
    
    
                return value;
            }
        </script>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" ScriptMode="Debug" />
        
            <ext:GridPanel runat="server">
                <Store>
                    <ext:Store ID="Store1" runat="server">
                        <Model>
                            <ext:Model runat="server" IDProperty="Id">
                                <Fields>
                                    <ext:ModelField Name="Id" Type="Int" />
                                    <ext:ModelField Name="Company" Type="String" />
                                </Fields>
                            </ext:Model>
                        </Model>
                    </ext:Store>
                </Store>
                <ColumnModel runat="server">
                    <Columns>
                        <ext:Column runat="server" Text="ID" DataIndex="Id" />
                        <ext:Column runat="server" Text="Company" DataIndex="Company" Flex="1" />
                    </Columns>
                </ColumnModel>
                <Plugins>
                    <ext:FilterHeader runat="server" OnCreateFilterableField="OnCreateFilterableField" />
                </Plugins>                    
            </ext:GridPanel>
        </form>
    </body>
    </html>
    Vladimir Shcheglov
    Sr. Developer

Similar Threads

  1. Replies: 6
    Last Post: Apr 27, 2016, 1:56 AM
  2. [OPEN] [#308] FilterHeader and infinite scrolling
    By HansWapenaar in forum 2.x Legacy Premium Help
    Replies: 16
    Last Post: Aug 05, 2013, 10:56 AM
  3. Default value for date type variable
    By emon in forum 1.x Help
    Replies: 10
    Last Post: Mar 10, 2011, 10:35 AM
  4. setting the default value of a date type column of store from backend ?
    By n_s_adhikari@rediffmail.com in forum 1.x Help
    Replies: 2
    Last Post: Oct 16, 2009, 6:35 PM
  5. Store Sort Type not working
    By bobs in forum 1.x Help
    Replies: 2
    Last Post: Feb 10, 2009, 10:01 AM

Posting Permissions