0 Replies Latest reply: Jun 24, 2016 9:16 AM by Adrian Piesiak RSS

    BackendApi ApplyPatches for dimensions reorder

    Adrian Piesiak

      Hello,

       

      I'm writing my own custom extension and I'd like to implement similar functionality to one present in native Pivot Table Extension which allows to change order of selected dimensions by dragging buttons, without entering edit mode. Since change which is done in Pivot Table is not permanent I assume that ApplyPatches method is used there with qSoftPatch flag set to true.

       

      In my own extension so far I was not able to change the order of dimensions, because I receive error 'Patch value not on valid JSON format.'

       

      My approach was to take one of the dimensions from Layout's qDimensionInfo, stringify it and apply it under different index like this:

       

      self.backendApi.applyPatches([

        { qPath: '/qHyperCube/qDimensionInfo/0', qOp: 'replace', qValue: JSON.stringify(layout.qHyperCube.qDimensionInfo[1]).split('"').join('\\"') },

        { qPath: '/qHyperCube/qDimensionInfo/1', qOp: 'replace', qValue: JSON.stringify(layout.qHyperCube.qDimensionInfo[0]).split('"').join('\\"') },

        ], true);

       

      Is this approach valid? If yes why am I receiving format errors?