Results 1 to 8 of 8

Thread: Using AutoLoad with function call instead of url

  1. #1
    Sencha User
    Join Date
    Feb 2014
    Posts
    29

    Default Using AutoLoad with function call instead of url

    Hi everyone,
    I've a doubt regarding autoLoad property of the Panel component. My panel has an ExtJs chart in it. The data required to plot that is inside a function which helps to plot the chart in the panel.

    AutoLoad It generally takes the url: 'users.json' / html / jsp page as input but is there a way to call a function for autoLoading and setting autoRefresh for that function to be called?
    like this :
    myPanel.getUpdater().startAutoRefresh(timer, callMe());

    Instead of :
    myPanel.getUpdater().startAutoRefresh(timer, '<%=request.getContextPath()%>/com/abc/webRep/web/ViewDashboard/myJsp.jsp');

    I've all required data inside that function. And I need to continuously refresh that panel along with the chart. Please help.

  2. #2
    Sencha User joel.watson's Avatar
    Join Date
    Nov 2014
    Posts
    3,120
    Answers
    446

    Default

    Hi dillu5c5--

    Yes, you should be able to do that. For example, the second argument of startAutoRefresh() is an object which, among other things, you can use to specify a callback method that should be called when the underlying load() method is complete.

    Something like:

    Code:
    var callbackFn = function( elLoader, success, response, opts ) {
        // do custom stuff here
    }
    loader.startAutoRefresh( timer, {
        callback: callbackFn
    })
    Hope that helps!

  3. #3
    Sencha User
    Join Date
    Feb 2014
    Posts
    29

    Default AutoLoad property configuration required

    Hi Joel Watson,
    Thanks a ton for the reply. It really helps me. But I'm confused with the 'autoLoad' config of the panel. What url must I specify in that? I don't need to hit any url to get the data.
    Please help

  4. #4
    Sencha User joel.watson's Avatar
    Join Date
    Nov 2014
    Posts
    3,120
    Answers
    446

    Default

    Quote Originally Posted by dillu5c5 View Post
    Hi Joel Watson,
    Thanks a ton for the reply. It really helps me. But I'm confused with the 'autoLoad' config of the panel. What url must I specify in that? I don't need to hit any url to get the data.
    Please help
    If you don't need to use an AJAX request in order to get the data, you might be better off using a different approach than the ElementLoader. Maybe a scheduled task would work better for your purposes? Using this you can still specify intervals at which your specific task would run, but not have to deal unnecessarily with remote requests.

    Hope that helps!

  5. #5
    Sencha User
    Join Date
    Feb 2014
    Posts
    29

    Default Creating array of tasks using Task Manager

    Hi Joel,
    Thanks a lot for your valuable suggestion. I've realised the task manager's importance for my need. I want to know if it is possible to create series of tasks like writing a for loop to create multiple tasks with respective intervals and run them.
    My requirement contains 4 charts in the same dashboard and they have individual time intervals to refresh. So I want to create series of tasks for each of them and run them.

    Please help.

  6. #6
    Sencha User joel.watson's Avatar
    Join Date
    Nov 2014
    Posts
    3,120
    Answers
    446

    Default

    Quote Originally Posted by dillu5c5 View Post
    Hi Joel,
    Thanks a lot for your valuable suggestion. I've realised the task manager's importance for my need. I want to know if it is possible to create series of tasks like writing a for loop to create multiple tasks with respective intervals and run them.
    My requirement contains 4 charts in the same dashboard and they have individual time intervals to refresh. So I want to create series of tasks for each of them and run them.

    Please help.
    Glad the suggestion was helpful. Regarding your other question, you can create as many tasks as you need. Are you having issues with creating them?

    Thanks

  7. #7
    Sencha User
    Join Date
    Feb 2014
    Posts
    29

    Default Problem with Looping in tasks

    Hi Joel,
    Thanks a lot for your valuable reply. I was able to create tasks individually without a loop. But my requirement needs to create tasks based on a loop. So in the loop, when I give the task creation logic, the timing was going wrong as JavaScript is Asynchronous.

    I hence rolled back to setAutoRefresh using CLOSURES {avoiding JS's async method} to solve my problem of refreshing the widgets.

    Now I've a new problem, when I use this setAutoRefresh() without URL and simply with CallBack function, I'm getting this in the firebug
    "POST http://localhost:8080/abc/DEF/Home/undefined 404 (Not Found) "

    Structure of my logic :
    Ext.getCmp('hiddenRefreshPanel'+i).getUpdater().startAutoRefresh(dashboardDetails.refreshTime, {
    callback: function(elLoader, success, response, opts ){
    refreshReportWidgets(i);
    }
    });
    How to get rid of this? Please help..

    Thanks,
    Dileep Kumar

  8. #8
    Sencha User joel.watson's Avatar
    Join Date
    Nov 2014
    Posts
    3,120
    Answers
    446

    Default

    Hi dillu5c5--

    Can you post a full test case here, or (ideally) by creating a runnable fiddle? Without seeing the context of your code, it's difficult to know what to suggest. If you can provide a test case, I'll be happy to help test it with you.

    Thanks!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •