1

I have method in Javascript:

function ServerSideDatasource(server) {
  return {
    getRows: function (params) {
      var response = server.getData(params.request).then((res) => {
        
        var result = {
          success: true,
          rows: res.rows,
          lastRow: getLastRowIndex(params.request, res.rows),
        };
   });
 }

Above method is called in TypeScript class:

    var datasource = ServerSideDatasource(getFiltersFromGrid);
    params.api.setServerSideDatasource(datasource);

From ServerSideDatasource I want to fetch number of rows. How to do that ?

Robert
  • 2,571
  • 10
  • 63
  • 95
  • 2
    Does this answer your question? [How do I return the response from an asynchronous call?](https://stackoverflow.com/questions/14220321/how-do-i-return-the-response-from-an-asynchronous-call) – briosheje Jul 29 '20 at 11:40

1 Answers1

0

You returned the function, so:

datasource.getRows();

Also, in the getRows function, return the result.

Axwabo
  • 49
  • 7