Author Topic: Asycn function inside getURL to form data  (Read 3228 times)

marruendarol

  • Pro Economy
  • Newbie
  • *
  • Posts: 2
    • View Profile
Asycn function inside getURL to form data
« on: July 23, 2014, 10:31:30 am »
Hi, i am trying to form my own data to send to the server by using getURL  but i need to check permissions in others tables to establish the final data to send to the Grid , the problem is that getURL is not async and it always return url & data before my querys are finish , is there a way to override this function or modify to make getURL wait for my database response?

Or as alternative solution ... any ideas how i can perform some database calls before appending data to getURL?

Example :

  getUrl: function (ui) {

        var queryObj = {}
        queryObj.pageNumber   = ui.pageModel.curPage;
        queryObj.nPerPage     = ui.pageModel.rPP ;
        queryObj.sortDir      = ui.dataModel.sortDir;
        queryObj.sortIndx     = ui.dataModel.sortIndx;

        var data = processPolicies(queryObj,function(data){
                 return { url: apiURL + "readCollection",  data: data};

})
        },


function processPolicies(queryObj,callback){
       $.ajax(.......

      success:  callback(response);

}



Ty in Advance.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Asycn function inside getURL to form data
« Reply #1 on: July 23, 2014, 04:49:21 pm »
getUrl is a sync callback function like any other js function.

you could do either of these:

1) make your ajax call a sync call in processPolicies.

or

2) use dataModel.location = 'local' and use $.ajax to load data in the grid.

marruendarol

  • Pro Economy
  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Asycn function inside getURL to form data
« Reply #2 on: July 23, 2014, 07:09:22 pm »
but if i do local , i will  lose remote paging and remote sorting functionallity?  or there is a way to combine it with grid  listeners?