I'm looking at the Hierarchy Grid Demo (http://demos.telerik.com/aspnet-mvc/grid/hierarchy) for inspiration on something similar I need to do.
In the demo, it's a list of people, and the detail grid shows orders placed for the person in the parent grid. So hypothetically, how would you implement a client side filtering condition that used data from the details to get a list of the parents? Say I want a list of all people who had orders shipped to Australia? Would I have to build a custom search, then populate the grid with the results, or is there a way to build that filter condition within the built in grid capabilities?
8 Answers, 1 is accepted
Well as it turns out, the whole hierarchy grid just isn't working. I built it similar to the demo, but the first grid doesn't load at all. If I take out the .ClientDetailTemplateId() method, the grid loads up just fine. But as soon as I try to put the .ClientDetailTemplateId in, it just stops reading for the first grid.
And of course, here's the code. First up, the controller. It's very simple:
And now the cshtml code:
Any help at all would be greatly appreciated...
So as you can see, I got the actual loading of the grid to work, however my issue now is the detail grid is shown in my hilight or selection bar color. In the demo, the background of the detail grid, behind the actual grid, is the selection color, but the grid itself comes out with a white background, making it totally readable.
In my grid (see attached screen shot) when I move my cursor over the detail grid, the entire grid lights up in the selection bar color of the parent grid. I'm sure I have some style somewhere that is mucking it up, but damned if I can find it. I really wish there were better methods for styling these damn things... ARGH!!
In the detail grid, I even have it set to select single rows, and still the entire grid lights up. It's not at all what I want, and I'm not sure what I need to muck about with to get it to look right. Any help?
Hopefully whomever from support reads this, I hope they just jump to the bottom and see this message...
My initial question still stands, about filtering the list of people in the parent grid based off of properties in the detail grid. Hopefully there's a way to easily implement this for the users without having to build custom search forms and a different page with the search results.
My second question about the coloring of the detail grid is still a legitimate question. I hate that the detail grid is colored the same as the hilight bar from the parent grid.
And thirdly, my detail grid I have grouped by a column. How can I get the detail grid to display with the groups all collapsed?
Regarding the questions:
1) The first Grid can be initially filtered using the filter property of the data source:
Filter property MVC
2) The colors can be set dynamically on the dataBound event of the child Grids:
3) This can be achieved by programmatically clicking the collapse icon on the dataBound event of the childGrid:
I hope this is helpful.
I'm afraid you either didn't completely read the message, or lost the actual issue in all the replies I left to my own message. I want to present to the user a way to filter the data in the topmost parent grid based off of information in the detail grid. To use the Hierarchial Grid demo as an example, the demo has a list of people, and the detail grid shows orders placed for the person in the parent grid. So hypothetically, how would you implement a client side filtering condition that used data from the details to get a list of the parents? Say I want a list of all people who had orders shipped to Australia? Would I have to build a custom search, then populate the grid with the results, or is there a way to build that filter condition within the built in grid capabilities?
2. I'll try the color thing, but I'm more interested in why the colors come out all wonky in the detail grid to begin with?
I'm sorry to hear that the suggestions were not helpful in the real application.
Based on the description of the desired result, this can be achieved with an external filter which can be set using the filter method of the Grid. The value can come from an input or from a variable. In general, the child Grids are filtered based on the parent, so filtering the parent based on the child is not supported, as parent Grid will be made first and it will not know the values of the child Grid before that:
If additional assistance is needed, please provide a fully runnable example, as this will allow us to provide suggestions best suited for the real application.