View.pager is null inside proxy.load() when setting datatable.pager as string

Hi,
I’m using Webix 3.2.2. I’ve just implemented dynamic loading as stated Olga’s blog and it works fine. Now want to implement paging. Unfortunatelly, I’m seeing that view.pager on my proxy load(view, callback, details) is null when datatable pager property is set to string. This doesn’t happen if pager is set to an object. So there is no way to know if datatable has a pager:

rows: [
{view: "datatable", datatype: "myProxy", url: "myUrl", pager: "myPager"}
:
{view: "pager", id: "myPager", size: 25, group: 5, template: ...}
]


webix.proxy.myProxy={
 $proxy:true,
 load: function(view, callback, details) {...} // <--view.config.pager, 
//view._settings.pager and view.getPager() are null during the first call. 
//Next calls, view.pager comes with the expected object.

 :
}

Regards

Hi,

that’s an expected behaviour, as pager has not been rendered yet. Firstly, the datatable renders and loads (upper row) and then pager is initialized (lower row).

To get to a pager to attach handlers to it you can use webix.delay method within the _attachHandlers function:

webix.proxy.myProxy = {
     $proxy:true,
     load:function(){...},
     _attachHandlers:function(){
         webix.delay(function(){
             var pager = this.getPager();
             //attach handlers to pager
          }, this); 
      }
}

Thanks Helga. Well, I see some risk on using webix.delay as it issues a window.setTimeout and some browsers differ on its implementation, varying from 4-10ms as mínimum delay resolution. So, I’ll try to keep my view pagers on top of datatables, in order to assure pager is rendered first. Regards

As alternative solution, you can replace the url option with a command.

separate $$("table").load 

As the command will be executed after ui creation, both datatable and pager objects will be available for sure.

Thanks Maksim, you are right. I’m using both approaches depending on the ui requirements.