Get and Set sorting info into rowFieldColumn on PivotGrid

Posted by: hanniewang on 8 August 2018, 5:37 am EST

  • Posted 8 August 2018, 5:37 am EST

    Hi Sir,

    I want to get and set up the sort information for the rowFieldColumn, but there are two ways I know it now:

    1. Using the itemFormatter() method to traverse the top left cells, to get and set the sort information,refer to: http://jsfiddle.net/ho0av8zq/12/;

    2. Using the engine.onViewDefinitionChanged(e) method, but I can't get the value of event.

    Do you have any suggestions?

    Best Regards,
    Hanny
  • Replied 9 August 2018, 5:35 am EST

    Hi,
    If we understand correctly then you would like to show current sort status also of rowFields.
    For that, you may set showRowFieldSort property of PivotGrid to true.
    Please refer to the following updated fiddle which implements the same:-
    http://jsfiddle.net/ec3z8ojb/

    As for 1 mentioned way, it is certainly possible that way but it is advised to keep only minimal processing in itemFormatter and avoid its use as much as possible for performance reasons.
    For the other mentioned way, it seems like you are raising the viewDefinitionChanged event using onViewDefinitionChanged() method(although not sure why) but to get the value of the event you would have to add handlers to the event like:-
    engine.viewDefinitionChanged.addHandler((s,e)=>{
    //do something
    });


    ~Manish
  • Replied 11 August 2018, 3:55 am EST

    Hi Manish,

    Thanks for your reply very much.

    I have setted showRowFieldSort property of PivotGrid to true. Maybe you don't fully understand my needs. My needs: When the user clicks on the rowField column, I can get the sort information for this column and save it; then, during the PivotGrid rendering, the sorting behavior of rowField columns in PivotGrid can be correctly rendered according to the saved sorting information.

    Last but not least, when I use viewDefinitionChanged() method, I really can't get the "event" value:

    engine.viewDefinitionChanged.addHaddler(function(s, e){
    console.log(s, e);
    // do something
    });

    However what I got was:




    Best Regards,
    Hanny

  • Marked as Answer

    Replied 13 August 2018, 6:27 am EST

    Hi,
    To get the sortInfo when a row field is sorted you may handle the sortedColumn event on the pivotGrid and perform required operation.
    Please refer to the following code snippet:-
    pivotGrid.sortedColumn.addHandler((s,e)=>{

    //check if row field sort
    if(e.panel.cellType!=wijmo.grid.CellType.TopLeft) return;

    let field= s.engine.fields.getField(e.panel.getCellData(e.row,e.col));
    let isDesSort = field.descending;
    //do something with this info

    });

    You may also refer to the following fiddle:-
    http://jsfiddle.net/w3qkhzec/


    >>>>>>>>>>>>>>>>>>>>>
    Last but not least, when I use viewDefinitionChanged() method, I really can't get the "event" value:
    <<<<<<<<<<<<<<<<<<<<<
    This is the default design behaviour as viewDefinitionChanged event passes EventArgs as the agrs argument which have no info associated with it.
    To get the viewDefinition inside the viewDefinitionChanged handler, you may use viewDefinition property.
    Please refer to the following code snippet:-
    engine.viewDefinitionChanged.addHandler((s,e)=>{

    let viewDef = engine.viewDefinition;
    //do somrthing with viewDef

    });


    ~Sharad
  • Replied 17 August 2018, 4:52 am EST

    Hi Sharad,

    Thanks for your help!O(∩_∩)O~~ I have finished my case.

    best regards,
    Hanny
Need extra support?

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

Learn More

Forum Channels