[CLOSED] ext:GridPanel. I need a listener that occurs before the Json webservice is invoked.

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] ext:GridPanel. I need a listener that occurs before the Json webservice is invoked.

    Hi!

    In my ext:Store, I trying call a DirectMethod (in another aspx page within another panel) that return a filter for my query.

    I'm using a listener BeforeLoad, but, this listener occurs when the data are returned and will be loading in gridPanel (appears to me).

    What listener of ext:Store or ext:GridPanel I can use to do this?

    <Listeners>
       <BeforeLoad Handler="if(parent.X.getCmp('panelFilter') != undefined){parent.App.panelFilter.getBody().App.direct.GetFilter({success: function(result){App.txtExternalFilter.setValue(result);}});};" />
    </Listeners>
    Last edited by Daniil; Apr 04, 2012 at 11:56 AM. Reason: [CLOSED]
  2. #2
    Hi,

    A load request doesn't wait then a DirectMethod will be executed. I.e. it calls a DirectMethod, then immediately makes a load request.

    At the first of all I would try to find a possibility to avoid such design.

    What actions do you call within the GetFilter DirectMethod? Can't they be performed client side?
  3. #3
    Hi Daniil!

    What actions do you call within the GetFilter DirectMethod? Can't they be performed client side?
    1 - I have a main page with two ext:Panels called panelFilter and panelData.
    2 - In panelFilter, I'm loading a aspx page (with loader of panel) with fields to set any params of filter to query loaded in panelData.
    3 - In panelData, I'm loading a gridPanel with data returned by Json webservice. The data loaded in gridPanel are dynamic, defined in a parameter of Json Webservice and depends of context.
    4 - The page loaded in panelFilter depends of the data loaded in panelData. If I load the Customers data in gridPanel in panelData, the panelFilter is loaded with a page that contains ext:TextFields and ComboBox to make a SQL WHERE statement to this context (Customer).

    Summarizing:
    The page loaded into panelFilter may vary depending on the context, and only the common access point of page within panelData to your filter is the directmethod getFilter. Diferent filter pages are implements this directmethod, returning a SQL Where Statment (or part of this).

    The way I found to be several pages of filter depending on the context (Customer, Supplier, Products) is this. But I'm open to suggestions.

    I do not know how to do on client side this. The page loaded in panelData donĀ“t know the details of page loaded in panelFilter. The page loaded in panelFilter should return to page loaded in panelData the sql where statment...

    Sorry about my difficult in express what I need. Thanks a lot for any help.
  4. #4
    Thanks for the details.

    Could you also demonstrate the code of the GetFilter method?
  5. #5
    Well... is a very simple code...

    The getFilter of CustomerFilter.aspx is:
    <DirectMethod()>
        Public Function GetFilter() As String
            Dim sFilter As String = ""
            
            If txtCity.Text <> "" Then
                sFilter = sFilter & IIf(sFilter <> "", " AND ", "") & "(City like '" & txtCity.Text & "')"
            End If
    
            If txtProfession.Text <> "" Then
                sFilter = sFilter & IIf(sFilter <> "", " AND ", "") & "(Profession like '" & txtProfession.Text & "')"
            End If
    
           If IsDate(dtStart.SelectedDate) And IsDate(dtEnd.SelectedDate) Then
                        sFilter = sFilter & IIf(sFilter <> "", " AND ", "") & "([CreatedIn] between convert(smalldatetime,'" & Format(dtStart.SelectedDate, "dd/MM/yyyy") & " 00:00',103) and convert(smalldatetime,'" & Format(dtEnd.SelectedDate, "dd/MM/yyyy") & " 23:59',103))"
                    End If
    
            If cmbStatus.SelectedItem.Value <> "-1" Then
                sFilter = sFilter & IIf(sFilter <> "", " AND ", "") & "(Status = " & cmbStatus.SelectedItem.Value & ")"
            End If
            
            Return sFilter
    The directmethod getFilter of TaskFilter.aspx is :
    <DirectMethod()>
        Public Function GetFilter() As String
            Dim sFilter As String = ""
            
            If txtCriador.Text <> "" Then
                sFilter = sFilter & IIf(sFilter <> "", " AND ", "") & "(Criador like '" & txtCriador.Text & "')"
            End If
            
            If txtExecutor.Text <> "" Then
                sFilter = sFilter & IIf(sFilter <> "", " AND ", "") & "(Executor like '%" & txtExecutor.Text & "%')"
            End If
            
            If txtEmpresa.Text <> "" Then
                sFilter = sFilter & IIf(sFilter <> "", " AND ", "") & "(Cliente like '" & txtEmpresa.Text & "')"
            End If
            
            If txtFornecedor.Text <> "" Then
                sFilter = sFilter & IIf(sFilter <> "", " AND ", "") & "(Fornecedor like '" & txtFornecedor.Text & "')"
            End If
            
            If txtOrigem.Text <> "" Then
                sFilter = sFilter & IIf(sFilter <> "", " AND ", "") & "(Origem like '" & txtOrigem.Text & "')"
            End If
            
            Select Case cmbPeriodo.SelectedItem.Value.ToUpper.Trim
                Case "0"
                Case "1"
                    If (IsDate(dtIni.SelectedDate) And IsDate(dtFim.SelectedDate)) AndAlso ((dtIni.SelectedDate <> #12:00:00 AM#) And (dtFim.SelectedDate <> #12:00:00 AM#)) Then
                        sFilter = sFilter & IIf(sFilter <> "", " AND ", "") & "([Prazo Inicial] between convert(smalldatetime,'" & Format(dtIni.SelectedDate, "dd/MM/yyyy") & " 00:00',103) and convert(smalldatetime,'" & Format(dtFim.SelectedDate, "dd/MM/yyyy") & " 23:59',103))"
                    End If
                Case "2"
                    If IsDate(dtIni.SelectedDate) And IsDate(dtFim.SelectedDate) AndAlso ((dtIni.SelectedDate <> #12:00:00 AM#) And (dtFim.SelectedDate <> #12:00:00 AM#)) Then
                        sFilter = sFilter & IIf(sFilter <> "", " AND ", "") & "([Prazo Final] between convert(smalldatetime,'" & Format(dtIni.SelectedDate, "dd/MM/yyyy") & " 00:00',103) and convert(smalldatetime,'" & Format(dtFim.SelectedDate, "dd/MM/yyyy") & " 23:59',103))"
                    End If
            End Select
            
            If cmbPrioridade.SelectedItem.Value <> "-1" Then
                sFilter = sFilter & IIf(sFilter <> "", " AND ", "") & "(Prioridade = " & cmbPrioridade.SelectedItem.Value & ")"
            End If
            
            If cmbStatus.SelectedItem.Value <> "-1" Then
                sFilter = sFilter & IIf(sFilter <> "", " AND ", "") & "(Status = " & cmbStatus.SelectedItem.Value & ")"
            End If
            
            Return sFilter
            
        End Function
    I will make many other filter, depending the context (data loaded in my gridPanel)...
  6. #6
    Seems, it's all might be implemented via JavaScript.

    I would implement it via JavaScript in the Filter page and call a JavaScript function instead of a DirectMethod.

    What about to port it to JavaScript? We strongly recommend to implement in JavaScript as much as possible. We would assist if you will be in trouble.

    Regarding to your initial request.

    You could return false from a BeforeLoad listener to prevent a load request. Then in a "success" handler you can call the Store reload function.

    Also you will need to lock a BeforeLoad listener from executing for calling reload function within a "success" DirectMethod handler.

    Something like this:
    store.locked = true;
    store.reload();
    store.locked = false;
    And place
    if (!store.locked) {
        // the BeforeLoad listener code
    }
    at the beginning of the BeforeLoad listener.

    But, repeat myself, I would port the GetFilter code to JavaScript.
  7. #7
    Hi Daniil!

    Thanks a lot for your help!

    I would like try your approach (port to Javascript)...

    Where do we begin?
  8. #8
    Well, porting the GetFilter to JavaScript step by step.

    Could you clarify where exactly are you in trouble?
  9. #9
    How I call the Javascript function getFilter in CustomerFilter.aspx (page contained in panelFilter)?

    In directmethod I do this:

    1 - Check if my parent page has a panel called panelFilter...
    2- Call the directMethod getFilter in page within panelFilter

    if(parent.X.getCmp('panelFilter') != undefined){parent.App.panelFilter.getBody().App.direct.GetFilter({success: function(result){alert(result);}});};
    I think that I need do:
    1 - Create in CustomerFilter.aspx, TaskFilter.aspx, etc a Javascript method called getFilter.
    2 - Call this Javascript function in my page that contains the gridPanel.

    But I don't know how I call the javascript function in aspx page contained in panelFilter.
  10. #10
    Generally, the same way:
    parent.App.panelFilter.getBody().javaScriptFunctionName()
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 2
    Last Post: Apr 11, 2012, 11:10 AM
  2. Replies: 7
    Last Post: Jun 15, 2011, 7:34 PM
  3. [CLOSED] Help: Custom find recod with JSON webservice
    By smart+ in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Nov 28, 2010, 12:20 PM
  4. [CLOSED] [1.0] Json Webservice DateTime Parsing Error
    By webclouder in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: Jun 04, 2010, 1:10 AM
  5. Replies: 1
    Last Post: Jul 14, 2008, 7:07 PM

Posting Permissions