PivotGrid have column or row without data

1 Answer 59 Views
PivotGrid
Mikael
Top achievements
Rank 1
Iron
Mikael asked on 06 Nov 2024, 09:17 PM

Hello,

I'm trying to create a pivot grid and I want to have all my equipment even if they have no data in the pivot grid but if I add a equipment with no employee there is a row with null in it. Is there a way of hidding the row if it has null or empty but still have the column with no data?

Here is an image of what I have

 

If that can help here is the data I have that populate the pivot grid

const data = [
    { inspectionId: 1, Equipment: "Test1", Employee: "emp1", nbInspection:5 },
    { inspectionId: 2, Equipment: "Test1", Employee: "emp2", nbInspection:3 },
    { inspectionId: 3, Equipment: "Test2", Employee: "emp3", nbInspection:2 },
    { inspectionId: 4, Equipment: "Test2", Employee: "emp1", nbInspection:3 },
    { inspectionId: 5, Equipment: "Test2", Employee: "emp2", nbInspection:2 },
    { inspectionId: 6, Equipment: "Test3", Employee: "emp3", nbInspection:5 },
    { inspectionId: 7, Equipment: "Test3", Employee: "emp2", nbInspection:2 },
    { inspectionId: 8, Equipment: "Test3", Employee: "emp2", nbInspection:1 },
    { inspectionId: 9, Equipment: "Test3", Employee: "emp1", nbInspection:3},
    { inspectionId: 10, Equipment: "Test4", Employee: null, nbInspection:0 },
    { inspectionId: 11, Equipment: null, Employee: "emp4", nbInspection: 0 },
];

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 08 Nov 2024, 09:30 AM

Hello Mikael,

I have to say that with the data that you are providing to the PivotGrid, the rendered result is expected.

If you want to remove the row with "null" Employee, you will have to remove it from the data that you are passing to the PivotGrid, since there is no way of hiding the row from within the component.

 

Regards,
Konstantin Dikov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Mikael
Top achievements
Rank 1
Iron
commented on 08 Nov 2024, 01:24 PM

Hello Konstantin,

That's unfortunate. Is there a way to add an empty column or row to the grid instead? 

Right now I did find a way to do something like I wanted, but I feel it's a bit weird. 

Instead of passing a null employee I pass one that exist and i set is value to 0 and then I add a custom cell to hide the 0 in the grid

The grid look like this

And I have a custum cell that remove any 0 in the grid

const customCell = (props) => {
    if (props.dataItem.data.value == "0" && !props.total) {
        props = {...props, children: ""};
    }
    return <PivotGridCell {...props} />;
}

Konstantin Dikov
Telerik team
commented on 11 Nov 2024, 08:20 AM

Hi Mikael,

Using a custom cell for changing the value would be a valid way of removing the "0" value from being the cells.

Tags
PivotGrid
Asked by
Mikael
Top achievements
Rank 1
Iron
Answers by
Konstantin Dikov
Telerik team
Share this question
or