5

In master/detail example, the expand/collapse icon is always present when setting [masterDetail]=true. However, my data sometimes does not have detail rows and I would like to hide the chevron in this situation. In my example, callRecords property would be present on the data but it would be null:

getDetailRowData: function(params) {
    params.successCallback(params.data.callRecords);
},

How can I not show the chevron on master grid when the data is null? Note: the example visible here: https://www.ag-grid.com/javascript-grid-master-detail-detail-grids/#detail-grid-options

2 Answers 2

6

This exact requirement is covered here in docs.

Basically you implement isRowMaster -

this.isRowMaster = function(dataItem) {
  return dataItem ? dataItem.callRecords.length > 0 : false;
};

From docs -

In specify which rows should expand, provide the grid callback isRowMaster. The callback will be called once for each row. Return true to allow expanding and false to disallow expanding for that row.

4
  • Perfect, thank you, for some reason I missed that part of the doc
    – Dodi
    Jun 11, 2020 at 9:53
  • @Pratik Bhat kindly also check my SO thread stackoverflow.com/questions/69272959/… Sep 21, 2021 at 21:46
  • That "callRecords" is an interface or what ? when i try to implement .length isn't working. Jan 30 at 3:27
  • @Saiprashanth - it is an example, a data field in question Feb 1 at 4:46
0

By adding Boolean value to isRowMaster in the gridOptions we can able to enable or disable the icon visibility

const gridOptions = {
    defaultColDef: {
        editable: false,
        filter: true,
        floatingFilter: true,
        floatingFilterComponentParams: { suppressFilterButton: false },
        resizable: true,
        sortable: true,
        suppressColumnsToolPanel: false,
        suppressMenu: true,
    },
    isRowMaster: dataItem => {
        return !(dataItem.Status === 'OFFLINE')
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.