Expand/Collapse Feature with Conditional Row in Flex Grid Layout

Posted by: nilesh_nichal on 19 May 2025, 9:35 am EST

    • Post Options:
    • Link

    Posted 19 May 2025, 9:35 am EST - Updated 19 May 2025, 9:40 am EST

    Hi Team,

    We are looking to implement a feature where a section can be expanded or collapsed, and where only a single row is displayed based on specific conditions related to a column’s value and source — as illustrated in the attached image.

    Our current layout is built using a flex grid. Could you please advise whether this functionality can be achieved using flex grid? If not, we would appreciate your recommendation on the most suitable layout approach or component library to implement this effectively.

    Additionally, it would be very helpful if you could provide a sample implementation or example to guide us.

    Looking forward to your suggestions.

  • Posted 20 May 2025, 7:40 am EST

    Hi Nilesh,

    As per the current FlexGrid structure, it would not be possible to achieve the exact same layout as in the attached image with the expand/collapse feature. However, the expand/collapse feature is available in FlexGrid with detail provider. Here’s the demo sample for your reference, you can take a look and use it if it fits your requirements well - https://developer.mescius.com/wijmo/demos/Grid/Master-Detail/NestedGrids(RowDetail)/angular

    Regards

  • Posted 20 May 2025, 8:27 am EST

    Thank you for your response. We’re on board with the direction provided, but we would appreciate some additional clarification and an example implementation. Specifically, we’d like to understand how the expanded row can display all the information across its respective columns when expanded, including options for “Expand All” and “Collapse All.”

    For eg : If we expand then data for Name and Description should be shown and not the other grid which we are doing in the above link.

    Thanks

  • Posted 21 May 2025, 7:54 am EST

    Hi Nilesh,

    While using ‘FlexGridDetailProvider’ in FlexGrid for a master-detail grid layout, FlexGrid adds a completely empty row below the target row when expanded. This detail row will not have any columns however, you can customize the content of this detail row as per your needs and insert any content that you want to show in the detail row. In the demo sample we shared, you’ll find two flexgrids. The first grid shows how you can insert custom HTML in the detail row, and the second grid shows how you can add another flexgrid in the detail row, if needed.

    You’ll have to customize the content as per your requirements. You can take a look at the demo sample for implementation and try adding your content to the detail row. In case, you face any issues, you can let us know.

    Here’s the API link for your reference, if needed - https://developer.mescius.com/wijmo/api/classes/Wijmo_Angular2_Grid_Detail.Wjflexgriddetail.html

    Please note that, it would not be possible the achieve the exact same layout as you shared in the screenshot previously. If you decide to have a layout that could be compatible with master-detail grid layout(i.e some data in columns in the master row, and some other data displayed below the parent row with custom styling as per your needs), then it could be a good fit to achieve your desired results.

    Regards

  • Posted 21 May 2025, 9:53 am EST

    Hi Team,

    Thank you for the clarification.

    Could you please create an example implementation and share it with us for reference? This would help us better understand how to structure the detail row content based on our specific requirements.

    Looking forward to your sample implementation.

  • Posted 22 May 2025, 8:20 am EST

    Hi Nilesh,

    Please find attached the master-detail demo sample for your reference. You can download the sample and take a look at the master detail implementation. We also found another solution for your requirements, which we missed last time. You can also use TreeGrid to display a similar layout to what you need. We have attached a sample for that also. It seems to be a better fit for your requirements. The treeGrid sample is just for demonstration purposes, that how you can implement parent-child layout in flexgrid and insert custom textboxes in the cells if needed. We have added static text to the input boxes, you can update it as per your needs. We have added necessary comments in the sample for your reference.

    You can also refer to the demo samples of TreeGrid here - https://developer.mescius.com/wijmo/demos/Grid/TreeGrid/EditableTreeGrid/angular

    API link - https://developer.mescius.com/wijmo/api/classes/Wijmo_Grid.Flexgrid.html

    Please note that, we have downloaded and modified the same demo sample as in the above link. You can also download the demo sample for offline reference if needed by clicking the ‘Zip’ icon above the code editor on our website demo samples. Please note that, you’ll have to customize the controls as per your requirements. You can gain a better understanding of the specific controls by exploring the documentation and API of the respective control on our site. You can also take a look at other demo samples for TreeGrid and other Wijmo controls by using the navigation pane on the left side on the website. You’ll get a complete overview of the features provided by the Wijmo controls there.

    In case, you still face any issues, while implementing or integrating the Wijmo control in your project, please let us know.

    Regards

    Grid_Master-Detail_NestedGrids(RowDetail)_Angular (1).zip

    Grid_TreeGrid_EditableTreeGrid_Angular.zip

  • Posted 23 May 2025, 4:57 am EST - Updated 23 May 2025, 5:02 am EST

    Hi Team,

    Thank you for your response.

    Just one more thing—could you please make a change to merge the cells in the “Name” and “Rate” column, as shown in the below screenshot?

  • Posted 26 May 2025, 8:28 am EST

    Hi Nilesh,

    You’ll have to use a custom merge manager for the grid to implement this type of merging. Please refer to the attached sample demonstrating the same. Please note that, we have added a custom merge manager class in ‘customMergeManager.ts’ file and also set the ‘allowMerging’ property on the columns whose cells should be merged. We have also used ‘merged-cells’ in cssClass for those columns and added some styles to display the content at the center in the merged cells. We have prepared the custom merging logic, assuming that there will be only a single level of hierarchy in the grid rows, you may need to update the code as per your project requirements.

    You can also refer to the following demo samples for a better overview of the merging cells in the grid - https://developer.mescius.com/wijmo/demos/Grid/Merging/CustomMerging/angular

    Regards

    Grid_TreeGrid_Updated.zip

  • Posted 28 May 2025, 5:57 am EST - Updated 28 May 2025, 6:04 am EST

    Hi Team,

    Thank you for your response. We were able to achieve our solution, but we’re encountering one issue.

    When a grouping row has no children (for example, when all related objects are removed from the check array), it gets incorrectly merged with another row. You can replicate this issue by using the following data in your app.data.ts file.

    Our expectation is that if a node has no children, only the parent node should be visible, and it should not merge with any other row.

    Please let us know how this can be resolved.

    import { Injectable } from "@angular/core";
     
    @Injectable()
    export class DataService {
      getWorkers() {
        return [
          {
            name: "Jack Smith",
            hours: 40.0,
            rate: 15.0,
            checks: [
              { type: 1, hours: 30.0 },
              { type: 2, hours: 510.0 },
              { type: 3, hours: 5.0 },
              { type: 4, hours: 20.0 },
              { type: 5, hours: 20.0 },
            ],
          },
          {
            name: "Mack Smith",
            hours: 40.0,
            rate: 100.0,
            checks: [],
          },
          {
            name: "Jane Smith",
            hours: 40.0,
            rate: 15.0,
     
            checks: [
              { name: "hourly", type: 2, hours: 30.0, rate: 15.0 },
              { name: "overtime", type: 2, hours: 10.0, rate: 20.0 },
              { name: "bonus", type: 2, hours: 5.0, rate: 30.0 },
              { name: "hourly", type: 2, hours: 20.0, rate: 18.0 },
              { name: "overtime", type: 2, hours: 20.0, rate: 24.0 },
            ],
          },
        ];
      }
    }

  • Posted 29 May 2025, 7:28 am EST

    Hi Nilesh,

    We have updated the custom merge manager class, applied restrictions not to merge the level 0 rows in the treegrid. Please refer to the updated sample for the same.

    Please note that, the row expand icon is not shown on the rows that do not have any children; hence, the expand icon will not be visible on the level 0 row, also, if it doesn’t have any children to expand.

    Regards

    updatedSample.zip

  • Posted 6 June 2025, 9:43 am EST - Updated 6 June 2025, 9:48 am EST

    Hi Team,

    Thank you for your response.

    We’re now able to implement our solution. Just one more thing—we’d like to know how to disable or hide the icon for a grouped row. Let me know how to do it with condition based hide

    Like in below screenshot, for the name column we have expand/collapse icon for Jack smith and icon is hidden for Mack Smith(you can assume the condition is based on rate, like if rate > 90 than icon is hidden, or any other condition depend on our use case)

  • Posted 9 June 2025, 3:12 am EST

    Hi Nilesh,

    You can handle the ‘formatItem’ event of the flexgrid for this purpose. You can remove the expand/collapse icon from the cells based on a custom condition as per your needs. Please refer to the updated sample for the same. In the sample, the expand/collapse icon is removed for the group rows whose hours are greater than 90.

    Regards

    updatedSample2.zip

  • Posted 1 July 2025, 2:00 am EST - Updated 1 July 2025, 2:11 am EST

    Hi Team,

    We’re currently experiencing some issues with the column filter functionality:

    1. When entering a value into the filter input, the Apply button becomes disabled preventing us from applying the filter. (you can see from below screenshot that core is there but apply button is missing screenshot 3 and 4)
    2. In some cases, even though a value is clearly present in the column applying the filter does not return any results. (you can see from below screenshot that model attribute is missing after searching SAP, screenshot 1 and 2)

    NOTE - We are using the filter -

     <wj-flex-grid-filter></wj-flex-grid-filter>

    Please resolve above queries and let me know if having any queries

  • Posted 1 July 2025, 8:25 am EST

    Hi Nilesh,

    Currently, you are using FlexGrid with hierarchical data, and filtering in hierarchical data is not yet supported in Wijmo, which might be causing this issue. You can refer to the attached sample that shows how you can modify the FlexGridFilter to work with hierarchical data. We have added ‘hierarchicalFilterUtility.ts’ file in the attached sample and used the required function to make the filter hierarchical inside the ‘initialized’ event handler function of the FlexGridFilter in the file ‘app.component.ts’

    It seems you have already applied some modification on the FlexGridFilter dropdown, the above solution should work in your case, however, if it doesn’t work, then please modify the attached sample as per your current filter implementation and share it with us so that we can have a better understanding of your project and assist you accordingly.

    Regards

    updatedSample3.zip

  • Posted 3 July 2025, 3:34 am EST - Updated 3 July 2025, 3:42 am EST

    Hi Team,

    Thank you for your previous response and the sample implementation using hierarchicalFilterUtility.ts. The solution helped resolve the issue where the “Apply” button was disabled despite a value being present in the filter input, and where filtering sometimes returned no results even though matching values existed.

    However, I’m facing a new challenge with how the filter behaves for hierarchical data:

    When I enter a specific value (e.g., WS1) in the filter input, the grid displays entire rows that contain WS1 in any child row. This includes parent rows with other child rows that have different values (e.g., GS1, Msauto). I would like the filter to show only the rows (parent and child) where WS1 is present, and exclude rows where the value is not found in any child.

    In other words:

    If WS1 is present in a child row, only that child row (and its parent if necessary) should be visible.

    Rows with other values like GS1 or Msauto should not be shown if they don’t match the filter input.

    Could you please guide me on how to modify the sample or the filtering logic to achieve this behavior?

    I’ve attached a screenshot for reference showing the current behavior.

    Looking forward to your guidance.

    please find the below code

    HTML

      <wj-flex-grid #flexGrid
                        [itemsSource]="gridData"
                        (initialized)="initGrid(flexGrid)"
                        headersVisibility="Column"
                        [selectionMode]="'Row'"
                        [stickyHeaders]="true"
                        [allowMerging]="'All'"
                        [childItemsPath]="['sources']"
                        >

    TS

    this.gridData = [
      {
        _id: 0,
        attribute: 'Manufacturing Date',
        sourceName: 'Msauto',
        displayAttributeName: 'Manufacturing Date',
        sources: [
          {
            _id: 1,
            attribute: 'Manufacturing Date',
            sourceName: 'WS1',
            isValidSource: true,
            displayAttributeName: 'Manufacturing Date'
          }
        ]
      },
      {
        _id: 2,
        attribute: 'Warranty Details',
        sourceName: 'Amazon',
        valueAttrPath: 'Titan_Cspec/Warranty Details_Impl/Sources#0/Value',
        isValidSource: true,
        displayAttributeName: 'Warranty Details',
        sources: [
          {
            _id: 3,
            sourceName: 'GS1',
            isValidSource: true,
            displayAttributeName: 'Warranty Details'
          },
          {
            "_id": 4,
            sourceName: 'SAP',
            isValidSource: true,
            displayAttributeName: 'Warranty Details'
          }
        ]
      },
      {
        _id: 5,
        attribute: 'Product Price',
        sourceName: 'Magento',
        isValidSource: true,
        displayAttributeName: 'Product Price',
        sources: []
      },
      {
        _id: 6,
        sourceName: 'GS1',
        isValidSource: true,
        displayAttributeName: 'Product Name',
        sources: [
          {
            "_id": 7 ,
            sourceName: 'Maximo',
            isValidSource: true,
            displayAttributeName: 'Product Name'
          },
          {
            _id: 8,
            attribute: 'Product Name',
            sourceName: 'Amazon',
            displayAttributeName: 'Product Name'
          },
          {
            _id: 9,
            sourceName: 'SAP',
            isValidSource: true,
            displayAttributeName: 'Product Name'
          },
          {
            _id: 10,
            attribute: 'Product Name',
            sourceName: 'WS1',
            isValidSource: true,
            displayAttributeName: 'Product Name'
          }
        ]
      },
      {
        _id: 11,
        attribute: 'Multiple Image Display',
        sourceName: 'WS1',
        displayAttributeName: 'Multiple Image Display',
        sources: []
      },
      {
        _id: 12,
        attribute: 'Colour',
        sourceName: 'SAP'
      }
    ];
    

  • Posted 3 July 2025, 8:32 am EST

    Hi Nilesh,

    It seems there has been some misunderstanding, the ‘Msauto’ and ‘GS1’ values highlighted in the screenshot you shared are the values from the parent item; they appear like a child due to the styling. However, we have updated the hierarchical filter code as per your requirements. Please refer to the attached sample for the same. Now, you can pass ‘HierarchicalFilterOptions.TargetOnly’ as the second parameter to the ‘makeFilterHierarchical’ method to only show the target rows that have the filtered values.

    In case, if there is something we missed, please let us know.

    Regards

    updatedSample4.zip

Need extra support?

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

Learn More

Forum Channels