question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Loading data thru function (including server-side pagination/sort/filter)

See original GitHub issue

Is there a way to use a function to load data instead of URL? This will be useful, if we are loading data thru other methodologies like websocket etc.

I have done the same by using an attribute source with following code changes. If required, can generate a PR. It worked for my use case as I used deferred to fetch the data in that called function.

In initServer function changed

	      if (!(url || this.options.url ) && !this.options.ajax) {
	        return;
	      }

as

	      if (!(url || this.options.url || this.options.source) && !this.options.ajax) {
	        return;
	      }

Then added following block in same function before var request=....

          if(this.options.source){
            let _res=this.options.source(data);
	          var res = Utils.calculateObjectValue(_this10.options, _this10.options.responseHandler, [_res, undefined], _res);

	          _this10.load(res);

	          _this10.trigger('load-success', res, true, undefined);

	          if (!silent) {
	            _this10.hideLoading();
	          }

	          if (_this10.options.sidePagination === 'server' && res[_this10.options.totalField] > 0 && !res[_this10.options.dataField].length) {
	            _this10.updatePagination();
	          }            
            
            return data;
          }

I am able to get data from the function defined as source:name-of-function

Is there any other better option?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
sekarpdktcommented, May 15, 2020

Ok. Solved it thru ajax:function(params) {ajaxhandler(additionalInfo,params); }

0reactions
sekarpdktcommented, May 15, 2020

Hi… Thanks. It solved original issue. I was having another request to send additional parameters to the AJAX function. This will be useful, if we have multiple tables in the same page and we wanted to have a common AJAX handler. Is there any option available to pass custom additional info to ajax handler in addition to params.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Server Side Pagination, Filtering, Search & Sorting with ag ...
In this video we go over:- How to implement server side functionality in ag grid with react- How to implement pagination, filter and...
Read more >
Add sorting, filtering, and paging - ASP.NET MVC with EF Core
In this tutorial you'll add sorting, filtering, and paging ... The column headings are links that the user can click to sort by...
Read more >
A server side external sorting and filtering example #2033
I myself was struggling with implementing a server-side sorting (data were a query to postgres) and came up with a solution that works...
Read more >
Front End Tables: Sorting, Filtering, and Pagination
I'm going to set up some data that includes a string, a number, a Boolean, and a date in the dataset, and enough...
Read more >
Introduction to Client Side and Server Side Pagination in ...
Pagination is a common Web UI technique that divides large data sets into multiple pages and displays one page at a time.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found