MIgration from version 4 to version 8

I have placed this topic in the Suite 7.0 category because I did not find a 8.0 one. I am responsible of migrating DHTMLX in our application from version 4 to version 8 and encountered a couple of problems for which I did not find answers in the documentation.

  1. I am trying to use the LazyDataProxy because we had “paginated” scrolling in our previous version and need to keep it that way, but for some reason when scrolling the grid does not do another request to the load url. I have tried enabling “dhx.scrollViewConfig.enable = true;” too. This is how I have configured the LazyDataProxy:

lazyDataProxy = new dhx.LazyDataProxy(‘<c:url value=“/load-dhtmlx8.do” />’, {
from: 0,
limit: 50,
delay: 150,
prepare: 5
});
grid.data.load(lazyDataProxy, “json”);
When the grid loads it does a GET request to “/load-dhtmlx8.do” placing “from=0” and “limit=50” as request parameters. How can I make the grid re-send the request once scrolling up and down with the updated from and limit ?

  1. Our application has a CSRFFilter which will block any POST request which does not have the token as parameter. Once adding a new row in the grid, it will make a POST request to the configured URL placing on the request the new row. It does not seem I can place any extra parameter on that request from the examples that I have read. Te way I am doing the save is:

grid.data.save(‘<c:url value=“/save-dhtmlx8.do” />’);

How can I send extra parameters to the save request ? In version 4 we used the setUserData() function at a “grid” level. Everything that was placed as User Data was send as part of the request. Does version 8 have a similar mechanism ?

  1. Filtering in version 8 seems to be only done on the client side, I don’t see any example where the load URL is called with some extra filter parameters so that you can do the filtering in the backend. Is backend filtering an option in version 8 ? If not how will the client filtering work with “paginated” scrolling when we have only 50 items loaded in the grid and we apply a filter ?

I have managed to fix the following issues:

  1. The LazyDataProxy will properly work if from the back end you bring the first LIMIT number of items, but set the total_count attribute as the entire set size. In my case I was setting the “limit: 30” and when returning from the backend had the “total_count: 30” when in fact I had 100 items in the database. So returning a valid JSON like (Please NOTE that the order of the attributes matters) :
    {
    data: [{}…{} → first 30 items],
    total_count: 100, (this is how many items I have in the db
    from: 0 (this needs to be updated after each scroll with the proper value)
    }
    Will make the lazy loading to work.
  2. I have received an official email from dhtmlx stating that the save() method can’t accept any extra parameters in the body/header of the POST/PUT/DELETE methods. The only way is to place the extra parameters in the URL like “grid.data.save(/myurl/something.do?extraParam1=value1&extraPatam2=value2&etc…)”

Now that issues 1 and 2 are fixed I went further and encountered 2 more issues for which I would appreciate some help.

  1. I need to do filtering in the backend, so basically I need to send somehow the filters set on the grid to my controller and return the proper dataset and redo the grid. I did not find any examples for this. Also as I have mentioned in my previous message I am using LazyDataProxy to load the data and when I try to do client side filtering using grid.data.filter I get a warning in the browser console “this method doesn’t work with lazyload”. Which would be the proper way to filter while using lazyload ?

  2. Another issue I have encountered is while exporting the grid to excel format using:
    grid.export.xlsx({
    name: “test_export”,
    url: ‘<c:url value=“/export-dhtmlx8.do”/>’
    });
    This will make a POST request to /export-dhtmlx8.do and place in the body a JSON with the entire information needed for export (columns, data, styles, etc). Now the issue I am facing is the fact that my data sent in the back end contains only the first 30 items (the limit set in the LazyDataProxy configuration), so I would be able to export only those. I need a way to export the entire dataset when no filter is applied. Does anyone know how I can achieve this ?

Thank you,
Robert Constantinescu

Hello Robert.

Unfortunately it is not available to perform filtering in case of data lazy loading mode.
The same thing is with the exporting, as it requires the data to be completely loaded to the grid for its exporting