SitePen / dgrid

A lightweight, mobile-ready, data-driven, modular grid widget designed for use with dstore
http://dgrid.io/
Other
628 stars 298 forks source link

dgrid does not throw error on scroll (http-status-code) #1479

Closed leo-combes closed 3 years ago

leo-combes commented 3 years ago

Hi, I'm implementing http-status-code in server responses and want to show an error if something go wrong. I want to know when the server send me an status like 401 (HTTP/1.0 401 Unauthorized) to show an error, and for that, I listen for dgrid-error:

grid = new (declare([ OnDemandGrid ]))({
    collection: new Request({ target: "cars", idProperty: 'car_id' }),
    columns: columns,
    minRowsPerPage: 50
 }, 'cars_table');

grid.on("dgrid-error", function(evt){
    console.log("dgrid-error");
    console.log(evt);
    console.log(evt.error.response.status);
});

If the server respond with an 401 status code when dgrid loads for first time, the error is triggered. The evt.error.response.status shows me 401, is OK.

But, once the table is loaded, if the server responds with an 401 status code while requests are made in scroll action, no error is triggered.

Both errors shoud be triggered from OnDemandList.js, but only triggers in initial dgrid load (line 238). Subsequent orders made by scrolling in dgrid, reach 'throw' in line 796, but no emit any 'dgrid-error'.

edhager commented 3 years ago

@leo-combes Changes have landed on master. Give it a try.

leo-combes commented 2 years ago

@edhager Sorry for the late reply. It works perfectly!