datastore group stack

edited June 2018 in Technical questions

Hi all,
is there a way to clear the datastore group stack? I called function group() twice
on datastore and I had to call ungroup() function twice to restore original data:


//outer group
g.data.group({
          by: function (obj) {
           return (obj.BANDESC == '' ? 'CASSA' : obj.BANDESC) + obj.PAGDESC;
          },
          map: {
           ENTRATE: ["ENTRATE", "sum"],
           USCITE: ["USCITE", "sum"],
           BANDESC: ["BANDESC"],
           PAGDESC: ["PAGDESC"]
          },
          row: function (o) {
           return "" + o.PAGDESC +
            " Entrate: " + o.ENTRATE +
            " Uscite: " + o.USCITE +
            " Saldo: " + webix.i18n.numberFormat(o.ENTRATE - o.USCITE) + "";
          }
         });

//inner group
g.data.group({
          by: function (obj) {
           return (obj.BANDESC == '' ? 'CASSA' : obj.BANDESC);
          },
          map: {
           ENTRATE: ["ENTRATE", "sum"],
           USCITE: ["USCITE", "sum"],
           BANDESC: ["BANDESC"]
          },
          row: function (o) {
           return "" + (o.BANDESC == '' ? 'CASSA' : o.BANDESC) +
            " Entrate: " + o.ENTRATE +
            " Uscite: " + o.USCITE +
            " Saldo: " + webix.i18n.numberFormat(o.ENTRATE - o.USCITE) + "";
          }
         });

         g.openAll();

and then

        g.data.ungroup();
        g.data.ungroup();

to reset to original data. Is there a better way ?
Thank you

Comments

  • Hello!
    You can completely reload the data.
    If the case is really hard, maybe it's better to group the data on server-side instead of our features.
    On the client - side there is no other solution. The point is that group it's client-side operation which is fully change the structure of the loaded data. In addition, you can group only one level at a time.

  • Thanks. Yes I know I can reload the data but in this use case it's expensive for me.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!