Issues with Grid, Json, SmartRendering, and .Net MVC Web API

I’ve got the grid loading data from my asp.net web api call that returns json. The data does display. But it’s not ever fetching any more rows. It makes that first call, I return the json object populated with total_count,pos, and the first 50 rows. The grid’s scrollbar is getting sized for those 50 rows I sent back and I can just scroll to the bottom and it never makes a call to fetch more rows. And worse, as I scroll up and down, I end up with rendered blank rows in the grid.

mygrid.enableSmartRendering(true, 50);
mygrid.load("/api/TestSearch/GetResults",“json”);

A snippet of what’s getting returned:

{“total_count”:2000,“pos”:0,“rows”:[{“id”:1,“data”:[“1”,“dffdg”]},{“id”:2,“data”:[“2”,“dfgdfggdfg”]},{“id”:3,“data”:[“3”,“h434f”]},{“id”:4,“data”:[“4”,“4f3g”]},

  1. What am i doing wrong? The docs say that this is supported in the Standard Edition. Why isn’t the scrollbar sizing itself for 2000 rows?

  2. I will be supplying my own filtering gui. How do I get the filtering data into the call? What about sort data? How can I get the grid to send along more data to the server?

  3. Is there any way for me to attach my own user data to the grid to send with each data request call?

  4. Can I get the grid to POST back when requesting data? Then hopefully I could send back a more structured json object with page to fetch, filters, sort, etc.

Unfortunately you need to include dhtmlxGrid_json.js to your page.
The library is available in PRO version only.

So what type of dynamic load on demand does the Standard Grid support?

Grid - Standard vs Pro Comparison Page

The comparison page says that “Smart Rendering with Dynamical loading” is supported in the StandardGrid.

DHX - Is this true or not?

standard version of dhtmlxGrid supports dynamic loading from the XML file.
In case of using JSON you will have to include dhtmlxgrid_json.js. The library is available in PRO version only.
So, the dynamic loading works well in standard version of the grid.

I’ve switched my web api call to return xml and now it’s working better. The scrollbar is sized correctly and I see the next call to load more data has posStart and count in it.

In looking through the filtering examples, none of them seem to be dynamic loading back to the webserver. It seems like all the data is downloaded to the client and filtering is being performed client side.

I am going to have my own custom filtering interface.

How can I get more data into that data request call back to the server? I need to supply filtering and sorting parameters. I guess every time the user changes the filter or applies a new sort, I could just reset to page 1 and call myGrid.loadXML again and pass everything on the query args, but then I’m limited in what I can send back.

Also, is there any flexibility in getting the grid to post back and send back some user data object in json or xml format?

You may try to use the NET. connector to implement the server-side filtration.
Here is the tutorial:
docs.dhtmlx.com/doku.php?id=dhtm … erver-side

I can’t use your connector because your connector seems like a take it all or leave type thing. I already have my own data access layer.

It would be nice if there was a way to tell your grid that is will be connecting to a connector, even though I will supply my own complete “connector” code and then I could just reverse engineer what data you are sending and react to it. But I tried setting some of your connector settings and the app then breaks. I think you should document how the grid interacts with your connectors so that we can supply our own complete versions of this.

So for now I am just trying to set the url. But still running into issues.

For example, sorting. I handled the before col sort event. I figured I would call grid.loadXML with a new url. I see that I am passed the index of the column being sorted. But…

  1. How do I know if it’s ascending or ascending? I can’t find any api call to get that.
  2. Does the grid support any concept of the user shift or ctrl clicking multiple columns to do a more complex sort?
  3. Is the grid still going to try and do a client side sort? Is there something special I need to do to disable all client side sorting?
  4. If I did have one of your connectors in place, what would it do? Would it automatically without hooking any event have made the server side call? And would that call have included the column and direction? If so, how can I get the grid to make that call automatically with that data and I just supply my own custom written connector? But then I still need the grid to include the filter from my own custom filter interface.

Ok, figures, after I posted, then a third look through the api just to be sure, and now I see a getSortingState. But it’s always empty. Since I was hooking BeforeSorting, I switch to AfterSorting event, but now, aaarggghh, that’s only in the Pro version.

I go back to the std vs pro comparison and it says the std version supports sorting and it supports clients and server side sorting. I don’t see anything that says the std version has restricted events api.

How can I get server side sorting to work in my sample application?

Ok, I do see the “restricted” events in the comparison whereby you just show the number of events.

For now, I’ve had to write a bunch of javascript in the onBeforeSorting event to get the column sort indicators to change and for a new server side call to get made with a new url that includes the column index and direction.

It seems like a lot of standard features only work if one uses YOUR connector. Is this the catch?

Otherwise, how does one out of the box make use of server side sorting without using your connector?

Here you can find an example of server-side soring without the usage of connector:
docs.dhtmlx.com/doku.php?id=dhtm … de_sorting