Custom POST Service Calling With WIJMO Pivot Grid : Angular 5+

Posted by: sachin.mishra on 24 July 2019, 1:50 am EST

  • Posted 24 July 2019, 1:50 am EST

    Hi Team,

    As of not pivot engine accepts the itemSource as the URL.By default it makes the GET Request. can you please suggest how to make the service call with POST service with formbody ?

    I have do it as promise service of type POST with custom post object.can you please help me out on the issue ?

    Thanks & Regards

    Sachin Mishra

  • Posted 24 July 2019, 7:28 pm EST

    Hi Sachin,

    Could you please tell us whether you are using C1 DataEngine service or SSAS cubes as the itemsSource of the PivotEngine. If you are using any of these, could you please confirm whether you would like to send the POST request for authentication purpose?

    If you are not using any of the above, then you will need to fetch the data using the httpRequest method which will return a JSON data that can be assigned to the PivotEngine. Refer to the sample below that demonstrates the same:

    https://stackblitz.com/edit/query-pivot-panel-chart-56dssl

    Regards,

    Ashwin

  • Posted 26 July 2019, 3:29 am EST

    Hi Ashwin,

    Thanks for your help,It worked out but in my service response have some null values which should not be considered in subtotals and grandtotals by Pivot Engine or Pivot grid.

    Is there any way to tell the pivot engine or grid to tell not consider Null values for subtotal and grandtotals calculation.

    Could you please give th share link for the same ?

    Regards,

    Sachin

  • Posted 28 July 2019, 3:20 pm EST

    Hi Sachin,

    The null values do not affect the calculation of subtotals and grand totals because while calculating the totals, the null values are not considered. You may verify the same using the sample below:

    https://stackblitz.com/edit/query-pivot-panel-chart-yygtng

  • Posted 28 July 2019, 9:58 pm EST

    Hi Ashwin,

    Thanks for your feedback,Please see the attachment where my data itself having the grandtotal value itself.I dont want wijmo to calculate the grandTotal Instead I am sending the value from backend should display as grandTotal Value. and subsequently should calculate the subtotal as well.

    Is there any way to that ? Please suggest.

    Subtotal & Grand Total Manipulation.zip

    Regards

    Sachin

  • Posted 29 July 2019, 4:15 pm EST

    Hi Sachin,

    From what I understand, the Category having null value contains the grand total and subtotal of the data. If all the grand total and subtotal have a null value, you can just filter out these values from the engine using the filter property of CollectionView. Please refer to the code snippet and the sample below:

    self.engine.itemsSource = [...];
    self.engine.rowFields.push('Category 1');
    self.engine.rowFields.push('Category 2');
    self.engine.valueFields.push('Amount');
    self.engine.valueFields.getField('Amount').format = 'c2';
    self.engine.collectionView.filter = (item, prop) => {
              return (item["Category 1"] && item["Category 2"]);
    }
    

    https://stackblitz.com/edit/query-pivot-panel-chart-r92ppq

    Let us know if this solves your issue or otherwise.

    Regards,

    Ashwin

  • Posted 29 July 2019, 11:00 pm EST

    Hi Ashwin,

    I don’t want the grid to calculate subtotal and grandtotal. Is there any way I can calculate the subtotal and grandtotal on server and the grid just display the data.

    Thanks,

    Sachin

  • Posted 30 July 2019, 3:55 pm EST

    Hi Sachin,

    We can add the custom subtotal and grand total to the PivotGrid using itemFormatter but it will have a couple of disadvantages like the data in PivotGrid will not be linked with PivotEngine and we will also have to ensure that the subtotal and grand total are added to their right position which will become difficult with large data sets. Could you please tell us why you do not wish to use the OLAP’s built-in calculation? Are you using some custom calculation on the server-side?

    ~regards

  • Posted 30 July 2019, 7:07 pm EST

    Hi Ashwin,

    I am calculating the subtotal and grand total with some custom calculation at the server side. we need the wijmo’s ui to display the content but not the subtotal and grandtoal.

    is there any way to do it with performance effective manner ? would like to add into your knowledge, we have already implemented the same thing in angular 1.5

    Please suggest.

    Regards

    Sachin

  • Posted 31 July 2019, 4:58 pm EST

    Hey Sachin,

    Please refer to the sample below:

    https://stackblitz.com/edit/query-pivot-panel-chart-dbi3ip

    I have updated the sample so that it uses the itemFormatter to update the values of subtotal and grand total according to the data from the server.

    Let me know if this works for you or if you have any additional questions.

    Regards,

    Ashwin

  • Posted 31 July 2019, 8:18 pm EST

    Hi Ashwin,

    Thanks Ashwin, That’s perfectly calculate the subtotals but need to display the server Grandtotal text and value if and only if code says it.

    Regards,

    Sachin

  • Posted 1 August 2019, 3:59 pm EST

    Hey Sachin,

    I am sorry but I was not able to understand your use case. From what I understand, you wish to show grand totals returned from the server in the PivotGrid only if the code says it otherwise the PivotGrid should show the original grand totals and subtotals. Please confirm that this is the desired behavior or otherwise.

    ~regards

  • Posted 5 August 2019, 11:11 pm EST

    Hi,

    I have started getting the wijmo.olap undefined when I updated the package to 5.20191.615 . I am making use of the followed prototype wijmo.olap._ServerConnection.prototype._sendHttpRequest to make the custom service call.

    Regards,

    Sachin

  • Posted 6 August 2019, 2:53 pm EST

    Hi Sachin,

    Starting from the build 5.20191.612, wijmo does not expose its modules to the global window object except the core module. This is the reason why wijmo.olap is undefined. You will need to import this module in your angular to use its classes and methods.

    Also, could you please let us know why you are using _sendHttpRequest method to send the custom service call?

    ~regards

  • Posted 7 August 2019, 12:22 am EST

    Hi Ashwin,

    The intention is trying to override _sendHttpRequest so that we can directly bind the data to wijmo pivot grid which has resolved at certain extend but facing the some issue related to formatting which has been fixed by wijmo in updated version but wouldn’t able to consume. would you please advise how to consume it the way you have defined in earlier conversation ?

    Also would like to make request related formatting in attached(PFA) related to pivot grid. Could you please advise ?

    Ref : https://stackblitz.com/edit/query-pivot-panel-chart-qdggap?file=src/app/app.component.html

    Attachement : How to make Cell Selection Highlighted in Pivot Grid.zip

    Regards

    Sachin

  • Posted 7 August 2019, 6:04 pm EST

    Hi Sachin,

    Regarding _sendHttpRequest method:

    Could you please provide more information on the issue like what formatting issue is arising, which version you were using before upgrading, where does the error occur, etc?

    Regarding highlighting the cells:

    We are working on the case and will provide you with further information or a sample as soon as possible.

    ~regards

  • Posted 8 August 2019, 5:16 am EST

    Hi Ashwin,

    Thank your for your feed back we are working with 5.20191.615 but there are some fixes have been given by wijmo in upgraded version i.e. 5.20191.615 but the abstraction has been restricted which causes the issue of _sendHttpReesut request.

    for your reference , Please find the attached code. The below code I have used for the custom service calling but after upgrading.Its breaking.

    [b]wijmo.olap._ServerConnection.prototype._getUrl = function (command, token, fieldName) {

    var url = old_getUrl.call(this, command, token, fieldName);

    if (command.toLowerCase() != ‘result’) {

    return url;

    }

    return ‘<<<Service_URL>>>’;

    }

    let olapData
    var customDefer
    wijmo.olap._ServerConnection.prototype._sendHttpRequest = function (cmd, settings) {
      switch (cmd) {
        case 'Analyses': // 
        case 'Status':   // 
          return;
        case 'Result':
          if (!settings) {
            settings = {};
          }
    
          // change the request type to POST
          settings.method = 'POST';
    
          // pass the view definition to the server.
          settings.data = {
          };
          // pass custom data to the server.
          settings.data.customData = {
            test1: this._ng.customData
          }
    
          customDefer = this._ng.customDefer;
          that.old_success[that.id] = settings.success;
          settings.success = function (resp) {
            that.old_success[that.id](resp);
            that.sub$.next(1);
          }
          settings.error = function (resp) {
            console.log('error');
          }
          that.old_sendHttpRequest.call(this, cmd, settings);
      }
    }
    

    [/b]

    Regards,

    Sachin

  • Posted 8 August 2019, 10:19 pm EST

    Hi Sachin,

    Regarding overriding _sendHttpRequest:

    We have queried the dev team on this issue. We will give you an update as soon as we hear from them.

    Regarding highlighting the cells:

    You may achieve this by using itemFormatter property of PivotGrid. Please refer to the sample below:

    https://stackblitz.com/edit/query-pivot-panel-chart-1jvaiq

    ~regards

  • Posted 12 August 2019, 6:21 pm EST

    Hi Ashwin,

    Thanks for the feedback,I was actually looking for the same issue that you given the solutions but was expecting the toggle features means when user click on the same cell the color should off if and only if its same cell when user had initially clicked and can we make it the same for the Column as well ?

    Once again thanks a lot for your help looking forward for the _sendHttpRequest and above mentioned ?

    Link for Column Data :

    https://stackblitz.com/edit/query-pivot-panel-chart-cvdgrf?file=src/app/app.component.ts

    Regards,

    Sachin

  • Posted 13 August 2019, 7:42 pm EST

    Hi Sachin,

    Please refer to the updated sample below:

    https://stackblitz.com/edit/query-pivot-panel-chart-u9aj4e

    In this sample, the background will be applied to the cells only when they are clicked twice and the column fields are colored as well.

    Regarding overriding the method:

    The issue is still with the dev team. We will give you an update as soon as we hear from them.

    ~regards

  • Posted 18 August 2019, 9:24 pm EST

    Hi Ashwin,

    Thanks for the feedback that really helps out, Did you find any solution for _sendHttpRequest issue ?

    Please advise,

    Regards

    Sachin

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels