Hi,
I have 3 bands of hierarchy in my grid. I am able to expand the first level but not able to expand the second level. I want my grid to look like below:
-R1
- T1
P1
But what I see is:
- R1
+ T1
I am using the following code:
function expandAllRowsOfGrid()
{
// get the top level grid
var parentGrid = $("#igGrid").igHierarchicalGrid("rootWidget");
$(parentGrid.allRows()).each(function (index, element) {
$("#igGrid").igHierarchicalGrid("expand", element);
$(element).children().each(function (indexChild, elementChild) {
$(element).igHierarchicalGrid("expand", elementChild);
});
}
$(element).igHierarchicalGrid("expand", elementChild); throws an exception.
Can you please suggest the correct way to open the second level.
Regards
S
Hello Singh,
Thank you for posting in our community.
You can check the following sample: https://www.igniteui.com/hierarchical-grid/hgrid-api-events
The "Expand All" button handler demonstrates how to expand igHierarachicalGrid all levels.
Please let me know if you need any further assistance with this matter.
Thanks Vasya,
It works fine now.
As I mentioned I have 3 levels in the grid. There is a possibility that sometimes the last band of grid may not have any data. Currently even if it does not have any data it shows the + sign in the parent and I am able to expand the grid and see nothing in it.
Is there anyway way I can stop the parent grid from showing any + sign if there are no rows in the child band?
In case that you are using igHierarachicalgrid with LoadOnDemand the "+" sign for expanding will always be visible. The reason is that igHierarachicalGrid has no information about the child levels until they are requested by clicking the expand icon. Some further information about Load On Demand feature may be found here.
Thank you for using Infragistics components.
Please let me know if you need any further assistance.
Hi Vasya,
Thanks for your reply.
I am initiliazing the grid in my controller using Load on demand and it doesn't gives me the above property in the controller. Only property I have there is
InitialExpandDepth
If I try to put it in the javascript as below:
$("#igGrid").igHierarchicalGrid({
initialDataBindDepth: -1
I get the below error:
JavaScript runtime error: initialDataBindDepth cannot be edited after initialization. Its value should be set during initialization.
Hierarchical grid provides initialDataBindDepth option. As you may assume from the options name it sets how many levels of the grid will be initially loaded. Option`s default value is -1 which means that initially all levels are going to be bound. In this case if you have a parent without any children the grid won`t render the "+" sign for expanding. Alternatively, if you set this option to 1, for example, and the third level is the one without children the grid does not have information about the data in the lower levels and will render the "+" sing in all cases.
I am attaching a small sample where the initialDataBindDepth option is not set (by default its is set to -1 which means that all data is loaded initially). In the third level there is no data respectively on the second level the "+" sign is not rendered. If you set the initialDataBindDepth option to 1 you may observe that in the second level the "+" sign is rendered.
Pleas let me know if you have any additional questions regarding this matter.