0

We are having a JQgrid with 3 level grouping applied. When we load the grid for the first time the column sum is getting rolled up successfully. We need to perform inline edit in the row and want the Group summary rows to get updated with the new value added. We have tried reloading the grid on aftersavefunc of editRow method but it is replacing the grid data with the server data. Is there a way we can refresh the Group summary row data when row is edited.

Thanks.

Oleg
  • 220,925
  • 34
  • 403
  • 798
supriya khamesra
  • 133
  • 3
  • 18
  • Which **version** of jqGrid you use? Could you post JavaScript code, which you use? Currently it's unclear how you implemented editing. Typically one save the modified data on the server and the `aftersavefunc` callback will be called only after you get the confirmation from the server, that the data are modified. Thus reloading of data should return modified data. Your current description of the problem is too short. One can guess, but it could be a lot of origins of the problem from usage of wrong options till usage of wrong caching properties of HTTP response (no reloading of new data). – Oleg Nov 07 '17 at 15:06
  • We are using free-jqgrid version 4.15.2. I have created a demo showing the grouping summary here https://jsfiddle.net/oyavoe00/ The column, columnmodel and data are in json format. Our issue is when we perform a row edit and update the value then we want that the corresponding group summary should also get updated on the screen without saving the data on the server. We are using our custom functionality to save the data from grid on a button click. We donot want to save the data on the server and get the data on edit save. – supriya khamesra Nov 08 '17 at 14:34
  • Look at https://jsfiddle.net/oyavoe00/1/. Is the problem exist here? – Oleg Nov 08 '17 at 15:22

1 Answers1

0

You can, for example, reload the grid after the end of inline editing.

inlineEditing: {
    keys: true,
    aftersavefunc: function () {
        var $self = $(this);
        setTimeout(function () {
            $self.trigger("reloadGrid");
        }, 0);
    }
}

It's recommended to use inlineEditing option in free jqGrid to set inline editing option. See https://jsfiddle.net/oyavoe00/2/

Oleg
  • 220,925
  • 34
  • 403
  • 798
  • Thanks Oleg. Your solution worked like a charm for me. But have one issue .As our data is coming from the server. When we display for the first time the group order is the one we needed but when grid loaded after inline edit the grid get sorted in alphabetical order of group values. Is there a way we can override group sorting and sort the data in grid on the basis of a column in the grid. Like there in the demo https://jsfiddle.net/5expwodw/3/ . I want to display the data on the basis of order field. – supriya khamesra Nov 09 '17 at 14:37
  • @supriyakhamesra: I'm not sure that I understand you correctly. Can one reproduce your problem on the demo https://jsfiddle.net/5expwodw/3/? Could you describe the test case step by step to reproduce the problem (inclusive expected results and the results of the demo)? I suppose that the the problems which you describe exists exist in your real code and not on the demo. Which `datatype` you use really? Do you make local reloading of data after editing or reloading from the server? – Oleg Nov 09 '17 at 15:52
  • In the demo the we want the data in the order we have under griddata variable. But after assigning to grid it is automatically get sorted . In my real code I am using Jon as data type and used loadonce : true otherwise it is fetching the data from server everytime grid was getting reloaded after edit. I think due it this grid is applying it's own sorting as I am not using any sorting on group. – supriya khamesra Nov 10 '17 at 00:58
  • @supriyakhamesra: You should post more realistic demo. The demo, which don't reproduce the problem, which you have, isn't helpful. If you use `datatype: "json", loadonce: true` in your real code, then the demo should do the same. JSFiddle provide Echo service for the case (see [here](http://doc.jsfiddle.net/use/echo.html)). In case of jqGrid you should send the JSON server response as `json` property of `postData`. See https://jsfiddle.net/52boyw5x/2/ as an example. – Oleg Nov 10 '17 at 08:13
  • @supriyakhamesra: About your main question: you should understand that grouping the data on the client side (after reloading) **require** sorting the data locally by `groupField`. You can specify `sorttype` or `sortfunc` for the columns "Level1", "Level2" and "Level3" so that it sort the data like you want. It's important that the *data* includes the information about sorting. You could at least include the order number of source row as integer found in the data. I recommend you additionally to read about `jqPivot` (see [here](https://github.com/free-jqgrid/jqGrid/wiki/jqPivot-in-version-4.9)) – Oleg Nov 10 '17 at 08:24
  • @supriyakhamesra: Look at [the answer](https://stackoverflow.com/a/41491962/315935) for an example of usage `jqPivot `. Your current code contains many other problems. For example, you use columns with names, which contains spaces (like `"name":"Feb - 2017"`). It's not allowed because names be used for ids and HTML5 don't allow ids with spaces. I'd recommend you to review your server side code (WCF code). I wrote you already that your serialize JSON data **twice**. Additionally I'd strictly recommended you to use `[DataMember(EmitDefaultValue = false)]` to clean-up `colModel` – Oleg Nov 10 '17 at 08:32