optimize performance in load data with a GridPanel multiheaders filter

  1. #1

    optimize performance in load data with a GridPanel multiheaders filter

    Hello everybody,

    I have a question and would like to ask for suggestions,

    I want to create something like this example:

    https://examples1.ext.net/#/GridPane...header/Filter/

    The problem is that depending on the number of records in the database makes the performance
    very slow. Following the example above, I developed something similar from the database,
    I wonder how I can make the multihead interfere directly in my select,
    maintaining the dynamic functionality without having to add button to see, how can I pass filters for parameter in my example
    select? Thanks

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
     If (Not Ext.Net.X.IsAjaxRequest) Then
     	Me.Store1.DataSource = Me.GetDataReader()
     	Me.Store1.DataBind()
    
     	Me.StoreNomeClientes.DataSource = Me.GetDataReader()
     	Me.StoreNomeClientes.DataBind()
     End If
    
    
     End Sub
    
     Protected Sub Store1_RefreshData()
     	Me.Store1.DataSource = Me.GetDataReader()
     	Me.Store1.DataBind()
     End Sub
    
    
     Public Function GetDataReader() As Object
     	Dim SqlConnection As SqlConnection = New SqlConnection("User ID=sa; Password=sa; Server=localhost; Database=DB;")
     	Dim SqlCommand As SqlCommand
     	Dim SqlDataReader As SqlDataReader
    
     	SqlConnection.Open()
     	SqlCommand = New SqlCommand("SELECT CodigoCliente,Nome,Cnpj,Rg,Contato FROM CLIENTE", SqlConnection)
     	SqlDataReader = SqlCommand.ExecuteReader()
    
    
     	Return SqlDataReader
     End Function
  2. #2
    Hi,

    Please investigate the following example.
    https://examples1.ext.net/#/GridPane...ilters_Remote/
  3. #3
    Thank you for helping Danill, this example could optimize the performance as follows:

        
    Protected Sub Store1_RefreshData(ByVal sender As Object, ByVal e As StoreRefreshDataEventArgs)
    
            Dim s As String = e.Parameters(Me.GridFilters1.ParamPrefix)
    
            Dim fc As FilterConditions = New FilterConditions(s)
            Dim value As String
    
            For Each condition As FilterCondition In fc.Conditions
                If FilterType.String Then
                    value = condition.Value
                End If
            Next
    
            If Not value = "" Then
                Me.Store1.DataSource = Me.GetDataReader(value)
                Me.Store1.DataBind()
            End If
    
    End Sub
    In my carry the value of the variable filter, which is passed as parameter in the query DataReader feeding my query.

    I wonder how I can change the layout of the filter, let him above the grid and not in, is it possible?
  4. #4
    Quote Originally Posted by danilo View Post
    I wonder how I can change the layout of the filter, let him above the grid and not in, is it possible?
    Hi danilo,

    To change a view of common filters will be too complicated.

    You could back to this example
    https://examples1.ext.net/#/GridPane...Header/Filter/

    Here is an example how you can achieve remote filtering using MultiHeader as filters.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <%@ Import Namespace="System.Linq" %>
    
    <script runat="server">
        private object[] MyData =
            new object[]
            {
                new object[] { "a" },
                new object[] { "b" },
                new object[] { "c" },
                new object[] { "a1" },
                new object[] { "b1" },
                new object[] { "c1" }
            };
    
        protected void RefreshStore(object sender, StoreRefreshDataEventArgs e)
        {
            Store store = sender as Store;
            string filter = e.Parameters["query"];
            if (string.IsNullOrEmpty(filter))
            {
                store.DataSource = MyData;
            }
            else
            {
                var filteredList = from x in MyData
                                   where (x as object[])[0].ToString().StartsWith(filter)
                                   select x;
                store.DataSource = filteredList;
            }
            store.DataBind();
        }
    </script>
    
    <!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 runat="server">
        <title>Ext.Net Example</title>
    
        <script type="text/javascript">
            var applyFilter = function(field) {
    
                GridPanel1.getStore().reload({
                    params: {
                        query: field.getValue()
                    },
                    callback: function() {
                        if (field) {
                            var id = field.id,
                                task = new Ext.util.DelayedTask(function() {
                                    var f = Ext.getCmp(id);
                                    f.focus();
                                    f.el.dom.value = f.el.dom.value;
                                });
                            task.delay(100);
                        }
                    }
                });
            };
        </script>
    
    </head>
    <body>
        <form runat="server">
        <ext:ResourceManager runat="server" />
        <ext:GridPanel ID="GridPanel1" runat="server" AutoHeight="true">
            <Store>
                <ext:Store runat="server" OnRefreshData="RefreshStore">
                    <Proxy>
                        <ext:PageProxy />
                    </Proxy>
                    <Reader>
                        <ext:ArrayReader>
                            <Fields>
                                <ext:RecordField Name="test" />
                            </Fields>
                        </ext:ArrayReader>
                    </Reader>
                </ext:Store>
            </Store>
            <ColumnModel runat="server">
                <Columns>
                    <ext:Column Header="Test" DataIndex="test" />
                </Columns>
            </ColumnModel>
            <View>
                <ext:GridView runat="server">
                    <HeaderRows>
                        <ext:HeaderRow>
                            <Columns>
                                <ext:HeaderColumn Cls="x-small-editor">
                                    <Component>
                                        <ext:TextField runat="server" EnableKeyEvents="true">
                                            <Listeners>
                                                <KeyUp Handler="applyFilter(this);" Buffer="250" />
                                            </Listeners>
                                        </ext:TextField>
                                    </Component>
                                </ext:HeaderColumn>
                            </Columns>
                        </ext:HeaderRow>
                    </HeaderRows>
                </ext:GridView>
            </View>
        </ext:GridPanel>
        </form>
    </body>
    </html>
  5. #5
    I tried to run the above example but could not, error occurred in the following line of code:

    error: expected;
    
    Line 26: else
    Line 27: {
    Line 28: var x = from FilteredList in MyData
    Line 29: where (x as object []) [0]. ToString (). StartsWith (filter)
    Line 30: select x;
    what could be wrong?

    Thanks for the help
    Last edited by geoffrey.mcgill; Nov 12, 2010 at 8:36 PM. Reason: please use [CODE] tags
  6. #6
    Hi,

    Seems there should be the newer compilator's verison.

    Please try to add the following thing into web.config

    Example
    <configuration>  
      <system.codedom>
        <compilers>
          <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider,System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">
            <providerOption name="CompilerVersion" value="v3.5" />
            <providerOption name="WarnAsError" value="false" />
          </compiler>
          <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">
            <providerOption name="CompilerVersion" value="v3.5" />
            <providerOption name="OptionInfer" value="true" />
            <providerOption name="WarnAsError" value="false" />
          </compiler>
        </compilers>
      </system.codedom>
    </configuration>
  7. #7
    Thanks Danill, could execute code

Similar Threads

  1. Replies: 1
    Last Post: May 31, 2012, 11:52 AM
  2. Load large Data in GridPanel
    By huzzy143 in forum 1.x Help
    Replies: 1
    Last Post: Feb 08, 2012, 4:54 AM
  3. [CLOSED] Clear Filter Data in GridPanel
    By speedstepmem4 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Apr 11, 2011, 12:51 PM
  4. Load Data into a GroupBox or GridPanel
    By miguelp120 in forum 1.x Help
    Replies: 0
    Last Post: Feb 11, 2010, 7:53 PM
  5. Replies: 4
    Last Post: Nov 17, 2008, 8:16 AM

Tags for this Thread

Posting Permissions