FlexSheet Automatically loads the last last sheet

Posted by: teenu.k on 8 December 2024, 10:19 am EST

  • Posted 8 December 2024, 10:19 am EST - Updated 8 December 2024, 10:34 am EST

    Hi,

    I have a flexsheet with default 2 sheets when one condition becomes true it will load 4 sheets .while loading 2 sheets , it will show the first sheet while loading but in case of 4 sheets .it will load the fourth sheet first. In that Go button highDeduct values becomes true or false.it is based on the program.

    This is my html code

    <wj-flex-sheet #flex (initialized)=“flexInitialized(flex)”>

    <wj-sheet [name]=“‘State Aggregate’” [itemsSource]=“stateData”>

    <wj-sheet [name]=“‘County Aggregate’” [itemsSource]=“countyData”>

    <wj-sheet *ngIf=“highDeduct” [name]=“‘State High Deduct Aggregate’” [itemsSource]=“stateDeductData”>

    <wj-sheet *ngIf=“highDeduct” [name]=“‘County High Deduct Aggregate’” [itemsSource]=“countyDeductData”>

    And my ts code is

    flexInitialized(flex: wjcGridSheet.FlexSheet) {

    var self = this;

    if (flex) {
      flex.selectedSheetChanged.addHandler(() => {
        if (flex.selectedSheet.grid['wj_sheetInfo']) {
          self._updateFonts(flex.selectedSheet.grid['wj_sheetInfo'].fonts);
        }
        self.columns = self._getColumns();
    
        self.isFrozen = self.flexsheet.frozenRows > 0 || self.flexsheet.frozenColumns > 0;
      });
    
      flex.selectionChanged.addHandler((sender: any, args: wjcGrid.CellRangeEventArgs) => {
        //  self._updateSelection(args.range);
        self.selectionFormatState = flex.getSelectionFormatState();
      });
      flex.selectedSheetIndex = 0;
    }  ,can you help to resolve? This is my Ui Screenshot [img]https://gccontent.blob.core.windows.net/discourse-forum-uploads/file-d700a65f-a883-4794-b77e-27ff86db2879.png[/img]
    
  • Posted 9 December 2024, 8:07 am EST

    Hi Teenu,

    In your provided code snippet, I noticed that the selectedSheetIndex prop is set to ‘0’ during the grid’s initialization. This is why the first sheet is rendered when the grid loads for the first time.

    By default, the last sheet added to the FlexSheet’s sheetCollection becomes the active sheet. To set the 4th last sheet as the active one, you’ll need to explicitly update the selectedSheetIndex to the desired sheet index.

    API link: https://developer.mescius.com/wijmo/api/classes/Wijmo_Grid_Sheet.Flexsheet.html#selectedsheetindex

    If you encounter any further issues or have any questions, feel free to reach out.

    Regards,

    FYI-Your shared image doesn’t seem to have been attached correctly.

Need extra support?

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

Learn More

Forum Channels