We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Hide row when no child shown after filtering

Hello,

I'm using SfDatagrid to display data. 

I have a first level grid which shows a pool of documents and a second level, a nested grid which shows the documents in the pool.

I can filter documents by their status ("Created", "Printed", etc)

First, I would like to know if I can hide a parent row if after filtering the grid the row hasn't any child ?
After that, I would get the filtered rows count, is it possible ?

I am attaching a sample project. I have a combobox to Filter the documents in the nested Grid by their status (an enum in my case).
I just want to hide the parents rows which haven't children when i change my filter, is it possible ?

Thank you in advance

Best Regards,
Marvin

Attachment: FilteringTest_275421b8.zip

3 Replies

JG Jai Ganesh S Syncfusion Team August 11, 2015 01:38 PM UTC

Hi Marvin,


Thank you for contacting Syncfusion Support.


We have analyzed your queries and please find the response for your queries as below,


                                     Query

                                       Answer

I have a combobox to Filter the documents in the nested Grid by their status (an enum in my case).

I just want to hide the parents rows which haven't children when i change my filter, is it possible?


You can achieve your requirement for hiding the parent row which haven’t children by set the row height as 0 based on the records count and detailsviewdefinition count in ComboBoxSelectionChanged event,


Code Snippet [C#]:


var recordsCount=this.datragrid.View.Records.Count;

var detailsviewdefinitionCount = this.datragrid.DetailsViewDefinition.Count;


var rowCount = (recordsCount * detailsviewdefinitionCount) + recordsCount;


var vc = this.datragrid.GetVisualContainer();

for (int i = 0; i < rowCount; i++)

{

      vc.RowHeights[i] = 0;

}

      vc.InvalidateMeasure();

We have also modified the sample based on this and please find the sample from the attached location:

I would like to know if I can hide a parent row if after filtering the grid the row hasn't any child ?

After that, I would get the filtered rows count, is it possible ?


We can not understand your query “To get the filtered rows count after hiding the row” clearly. Could you please share more information about your query? This would be more helpful for us to serve you in better way.


Sample: http://www.syncfusion.com/downloads/support/directtrac/142249/ze/FilteringTest1562474235


Please let us know if you need further assistance.


Thank you,

Jai Ganesh S



MN Marvin Niefer August 11, 2015 03:04 PM UTC

Hi,

Thank you for the answer.

But it doesn’t solve my problems, maybe I wasn't enough specific. I will explain again what I would like to do, maybe it would be easier to understand.

I have my SfDatagrid, that doesn't change.

 Original Grid State

I would like to show the documents only if their status matches the combobox selected Status.

I use the filterpredicate to achieve that. It works fine.

When I Filter on Created Status

But I want to hide the rows when there are no rows in the nested grid after filtering the status.

In this picture, there is a row which hasn't documents with the "Sent" status.

After filtering on Sent Status

My questions are :

-How can I determine if my parent's row has some filtered children (documents with the same status as my combobox selected status) ? And if I can get those children ? 

I saw a "ChildViews" property on the RecordEntry, but it was often null even if my row has some children.

-How can I hide the childless rows when I change my filter, so hiding when there are no children with the same status as the combobox selected status ? (And doing it every time I change the filter)


And I have a question on your solution

-In your snippet, you are hidding all the lines, not only the childless ones, and I don't understand why 

var rowCount = (recordsCount * detailsviewdefinitionCount) + recordsCount;

Because in my sample, if I look on vc.RowHeights.LineCount, I get 21 and rowCount = 20, maybe is the grid header included in that count ?

It would say that RowHeights only counts the parents' rows and the header of each detailViewDefinition and not the detailViewRow count ?

I don't attach my sample again, this is the same, I just change the data to take the screenshots.

I hope I can help you better to understand my questions. And sorry for asking again.

Best regards, 

Marvin.




JG Jai Ganesh S Syncfusion Team August 13, 2015 02:10 AM UTC

Hi Martin,


Thank you for the update


We analyzed your query. A support incident to track the status of this query has been created under your account. Please log on to our support website to check for further updates


https://www.syncfusion.com/account/login?ReturnUrl=/support/directtrac/incidents


Please let me know if you have any questions.


Thank you,

Jai Ganesh S


Loader.
Live Chat Icon For mobile
Up arrow icon